ASP.Net - Gridview row selection and effects

Posted by Clint on Stack Overflow See other posts from Stack Overflow or by Clint
Published on 2010-06-15T17:56:33Z Indexed on 2010/06/15 18:02 UTC
Read the original article Hit count: 235

Filed under:
|

I'm using the following code in attempt to allow the user to select a gridview row by clicking anywhere on the row (plus mouse over and out) effects. The code doesn't seem to be applied on rowdatabound and I can't break into the event. (It is wired).

The control is in a usercontrol, that lives in a content page, which has a masterpage.


    protected void gvOrderTypes_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        GridView gvOrdTypes = (GridView)sender;

        //check the item being bound is actually a DataRow, if it is,   
        //wire up the required html events and attach the relevant JavaScripts
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes["onmouseover"] = "javascript:setMouseOverColor(this);";
            e.Row.Attributes["onmouseout"] =  "javascript:setMouseOutColor(this);";
            e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(gvOrdTypes, "Select$" + e.Row.RowIndex);
        }
    }

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about gridview