We help IT Professionals succeed at work.

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

dipster307
dipster307 asked
on
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

Comment
Watch Question

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

Explore More ContentExplore courses, solutions, and other research materials related to this topic.