开发者

ASP.Net - Gridview row selection and effects

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜