p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Professional (http://p2p.wrox.com/forumdisplay.php?f=215)
-   -   Select row in GridView WITHOUT using Select button (http://p2p.wrox.com/showthread.php?t=65917)

rao965 February 15th, 2008 09:33 AM

Select row in GridView WITHOUT using Select button
 
Hi,
I have two GridView (Master/detail) controls on the same page. I want to be able to populate the second GridView when I click on each row in first GridView without showing the Select button or ID field on the first GridView. I have used RowDataBound event to make each rows selectable as follows but I can not get the value of ID field. Is anyone has an idea how should I approch this. Mant thanks in advance for your help.
Code:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.BackColor='Yellow';";
            e.Row.Attributes["onmouseout"] = "this.style.BackColor='red';";

            e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex);


        }

    }



Regards

Rao

planoie February 15th, 2008 10:44 AM

In what code are you trying to get the ID? I don't see anything here that addresses that.

You can set your ID column as one of the DataKeys for the control. That way in a postback you can get the ID value out of the grid item without needing to display it.

-Peter


All times are GMT -4. The time now is 12:58 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.