Determine which cell was clicked in datagrid

calvin

Regular
Joined
Nov 6, 2003
Messages
71
Hi,

I got a problem of how to identify the cell was clicked in datagrid. In my datagrid, there are 10 template column and each column have a label and image button. I want to hide the label when user click the image button.

I do not know which row of cell is clicked but column. I create a command to the button, for example:

HTML:

<asp:ImageButton id="btnEdit1" runat="server" ImageUrl=="../Images/Icon.gif" CommandArgument="1" OnClick="GetControl"></asp:ImageButton>

CodeBehind(VB.NET)

Public Sub GetControl(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)

Select Case "e.CommandArgument"
Case "1" 'Column 1
Dim Label1 as Label = DataGrid1.item(??).FindControl("Label")
Label1.visible = False
Case "2" 'Column 2
...
End Select

End Sub

Notice the ??(row), how can I get it???????

I was struggle on this problem couple of day, appreciate for any help! :)

Calvin
 
Back
Top