How to determine which cell was clicked in as ASP.NET DataGrid

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Daniel Walzenbach (daniel.walzenbach.NOSPAM_at_freudenberg.de)
Date: 06/01/04


Date: Wed, 2 Jun 2004 00:12:59 +0200

Hi,

 

I created an ASP.NET Datagrid where a single row can be selected by clicking anywhere on the row (according to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchTopQuestionsAboutASPNETDataGridServerControl.asp, Selecting Rows by Clicking Anywhere).

 

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, _
      ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
      Handles DataGrid1.ItemDataBound
   Dim itemType As ListItemType = e.Item.ItemType
   If ((itemType = ListItemType.Pager) Or _
      (itemType = ListItemType.Header) Or _
      (itemType = ListItemType.Footer)) Then
      Return
   Else
      Dim button As LinkButton = _
         CType(e.Item.Cells(0).Controls(0), LinkButton)
      e.Item.Attributes("onclick") = _
         Page.GetPostBackClientHyperlink(button, "")
   End If
End Sub
 
Additionally I want to be able to know which cell was clicked. Does anybody know how this can be done?

 

Thank you a lot in advance!

 

   Daniel


Quantcast