?
Solved

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

Posted on 2016-09-21
4
Medium Priority
?
72 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:Murray Brown
[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
  • 2
4 Comments
 
LVL 10

Expert Comment

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

Author Comment

by:Murray Brown
ID: 41808874
yes please
0
 
LVL 12

Accepted Solution

by:
Ramkisan Jagtap earned 2000 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:Murray Brown
ID: 41810166
Thanks very much
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

741 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