Click here to Skip to main content
15,892,805 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
Hi,
I have multiple Buttons in Table tag. how should i compare text of buttons. I have following function but it returns Tablerowcollection and does not further to check control inside that row.

how should i do it?

following is my code-

VB
For Each ctl As Control In selectSort.Controls
    Dim button As System.Web.UI.WebControls.Button = TryCast(ctl, System.Web.UI.WebControls.Button)
    If button IsNot Nothing Then
        If button.Text = btn_Filter1.Text Then
            button.Visible = True
            btn_Filter1.Visible = False
        End If
    End If
Next


selectSort is Table ID
Posted
Comments
ZurdoDev 17-Jun-14 8:12am    
Your title does not seem to match your description. It is not clear where you are stuck.
SRS(The Coder) 18-Jun-14 1:11am    
Please elaborate a bit more.
[no name] 19-Jun-14 5:34am    
Dear your question & subject line didn't matched. Please update your question.

1 solution

Try This :

VB
For Each tblRw As Control In selectSort.Controls
    For Each tblCell As Control In tblRw.Controls
        For Each ctl As Control In tblCell.Controls
            Dim button As System.Web.UI.WebControls.Button = TryCast(ctl, System.Web.UI.WebControls.Button) 
            If button IsNot Nothing Then
                If button.Text = btn_Filter1.Text Then
                    button.Visible = True
                    btn_Filter1.Visible = False
                End If
            End If
        Next
    Next
Next
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900