GridView - javascript 触发后台 OnSelectedIndexChanged

1.ASPX

<asp:GridView ID="gdvDealers" runat="server" AutoGenerateColumns="False"
        CssClass="tableData" Style="margin: 0px;" OnRowDataBound="gdvDealers_RowDataBound" OnSelectedIndexChanged="xxx"

2.ASPX.cs

protected void gdvDealers_RowDataBound(object sender, GridViewRowEventArgs ev)

            if (ev.Row.RowType == DataControlRowType.DataRow)
            {
                ev.Row.Attributes["onmouseover"] = "this.style.cursor='hand';this.style.textDecoration='underline';";
                ev.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
                for (int i = 0; i < ev.Row.Cells.Count; i++)
                {
                    if (i == 0) continue;
                    ev.Row.Cells[i].Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.gdvDealers, "Select$" + ev.Row.RowIndex);
                }

3. UI result

Asp.net javascript:__doPostBack('ctl00$MainContent$gdvDealers','Select$0')

posted @ 2015-09-14 10:26  webglcn  阅读(429)  评论(0编辑  收藏  举报