Solved

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

Posted on 2016-09-21
4
64 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
[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: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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

728 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