GridView-弹出模式窗口

来源:互联网 发布:网络语草根是什么意思 编辑:程序博客网 时间:2024/06/13 08:14

界面:

gridview控件中:

 <asp:TemplateField HeaderText="操作">
     <ItemTemplate>
     <img alt="" src="img/update.jpg" />
     <asp:HyperLink ID="HyperLinkUpdate" runat="server"><span style=" cursor:pointer">编辑</span></asp:HyperLink>
     </ItemTemplate>
</asp:TemplateField>

说明:<span style=" cursor:pointer">表示鼠标移到“编辑”上时变为手的形态。

后台:

  protected void gdvYYH_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowIndex != -1)
        {
            string YYSBM =gdvYYH.DataKeys[e.Row.RowIndex].Value.ToString();
            ((HyperLink)e.Row.FindControl("HyperLinkUpdate")).Attributes.Add("onclick", "javascript:var s=window.showModalDialog('YHYYSModify.aspx?YYSBM=" + YYSBM + "',window,'dialogwidth:500px;dialogheight:430px;help:0;center:yes;resizable:0;status:0;scroll:no');if(s==1) location.href='Default.aspx';");
        }
    }

原创粉丝点击