Solved

How to handle doubleClick event in datagrid?

Posted on 2006-06-16
5
461 Views
Last Modified: 2012-08-13
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
Comment
Question by:Abdu_Allah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
kGenius earned 500 total points
ID: 16926171
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
 
LVL 7

Expert Comment

by:kGenius
ID: 16926173
Then you catch the event with OnSelectedIndexChanged on read the data of the selected row
0
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 16926205
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
 
LVL 7

Expert Comment

by:kGenius
ID: 16926307
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
 
LVL 3

Author Comment

by:Abdu_Allah
ID: 16926386
Thank you it is work fine now that you.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question