• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 470
  • Last Modified:

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.
0
Abdu_Allah
Asked:
Abdu_Allah
  • 3
  • 2
1 Solution
 
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now