Solved

How to handle doubleClick event in datagrid?

Posted on 2006-06-16
5
442 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
  • 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now