How to handle doubleClick event in datagrid?

Hi, I am looking for a code in VBScript to handle doubleClick event in datagrid that return row data when I doubleclick on a row?

Thanks.
LVL 3
Abdu_AllahAsked:
Who is Participating?
 
kGeniusCommented:
Private Sub DataGrid_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemCreated
 
  Dim DataGridID As String = CType(sender, DataGrid).ID + "$"
   
  If (e.Item.ItemType = ListItemType.Item) OrElse (e.Item.ItemType = ListItemType.AlternatingItem) OrElse(e.Item.ItemType = ListItemType.SelectedItem) Then
       e.Item.Attributes.Add("ondblclick", "javascript:__doPostBack('" + DataGridID + "_ctl" + (e.Item.ItemIndex + 3).ToString + "$_ctl0','')")
  End If
End Sub


Hope this'll help
kGenius
0
 
kGeniusCommented:
Then you catch the event with OnSelectedIndexChanged on read the data of the selected row
0
 
Abdu_AllahAuthor Commented:
Could you please explain how to catch the event with OnSelectedIndexChanged on read the data of the selected row
If there is a sample code that will be better. Thanks.
0
 
kGeniusCommented:
ie
Protected Sub DataGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.SelectedIndexChange

  'read your data here ie:
  Dim myProperty = DataGrid1.SelectedItem.Cells(0).Text
  'etc...
End Sub



One other remark in your HTML code (datagrid columns) you must provide a ButtonColumn
<asp:ButtonColumn HeaderText="" ButtonType="LinkButton" Text="Select" CommandName="Select">
You can set Visible=false .
But it's needed to simulate the "Select" command provided by the doubleclick javascript in the previous post.

Hope this 'll help
kGenius
0
 
Abdu_AllahAuthor Commented:
Thank you it is work fine now that you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.