how to make rows clickable, datagrid, in asp.net

I have created coding to read xml file, place it in dataset and put it in datagrid. However I want to make the rows clickable each row opens a specific page.

            XmlDocument loadXML = new XmlDocument();
            loadXML.Load(Server.MapPath("Data.xml"));
            XmlNodeReader xmlReader = new XmlNodeReader(loadXML);
            DataSet dataSet = new DataSet();
            dataSet.ReadXml(xmlReader);

            myDataGridviewV2.DataSource = dataSet;
            myDataGridviewV2.DataBind();

Open in new window

dipster307Asked:
Who is Participating?
 
rajapandian_81Connect With a Mentor Commented:
Hi,

Refer the following links:
http://www.aspdotnetfaq.com/PrinterFriendlyFaq/How-to-correctly-highlight-GridView-rows-on-Mouse-Hover-in-ASP-NET.aspx
http://code.msdn.microsoft.com/GridViewRowEventSupport-48597096
http://www.netomatix.com/development/gridviewrowhighlight.aspx

In datagrid's "OnRowCreated" event, you can add the "onclick" attribute for each row and redirect to different page on row click.

For eg.,
e.Row.Attributes.Add("onclick", "window.location.href='" + e.Row.Cells[0].Text + "'");

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.