Solved

ASP.net Get row index of dynamically added GridView on click

Posted on 2016-09-21
4
40 Views
Last Modified: 2016-09-22
Hi. I add a GridView to my ASP.net page using the following code. I want to be able to get the rowindex
of the GridView when it is clicked. How do I do this?

                        Dim oGridView As New GridView
                        oGridView.ID = "Control" & CStr(oCount)
                        oGridView.Style("Width") = "100%"

                        oGridView.Attributes.Add("onkeydown", "return (event.keyCode!=13);")

                        Dim bImageField As New ImageField()
                        bImageField.DataImageUrlField = "Text1"
                        oGridView.Columns.Add(bImageField)

                        oLoadGrid(oGridView, "Select * From Test2")

                        Me.Panel_Controls.Controls.Add(oGridView)
0
Comment
Question by:murbro
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Paweł
ID: 41808801
do you want to get it on the client or server side?
0
 

Author Comment

by:murbro
ID: 41808874
yes please
0
 
LVL 12

Accepted Solution

by:
Ramkisan Jagtap earned 500 total points
ID: 41810152
You can do it using onrowdatabound and onelectedindexchanged events of gridview. Following is a very good article:

http://www.aspsnippets.com/Articles/Selecting-GridView-Row-by-clicking-anywhere-on-the-Row.aspx
0
 

Author Closing Comment

by:murbro
ID: 41810166
Thanks very much
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 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

8 Experts available now in Live!

Get 1:1 Help Now