views:

32

answers:

2

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);
        }
    }

A: 

Scratch that. The handler was wired to the databound event instead of rowdatabound. Sorry everyone. As a side note, the code works :)

Clint
A: 

Any chance you could post your full sample code? I am trying to do the exact same thing (clicking a gridview row and triggering a server side event from it), but my server side event never seems to trigger for some reason...

kenneth