gridview 打开新页 并且传递参数

本文介绍如何在ASP.NET的GridView控件中添加带有报告单链接按钮的模板列,并通过Command事件实现弹窗打开指定页面的功能。具体实现包括定义模板列内的LinkButton属性及设置事件响应,以获取当前行的主键参数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在 gridbview 中添加模板列

<ItemTemplate>
          <asp:LinkButton ID="LinkButtonReport" runat="server" CausesValidation="False"Font-Size="12px" ForeColor="DimGray" Text="报告单" CommandArgument='<%#Bind("RecNumb")%>' OnCommand="LinkButtonReport_Command"></asp:LinkButton>
                            </ItemTemplate>

 

 

然后编写事件

protected void LinkButtonReport_Command(object sender, CommandEventArgs e)
    {
        string RecNumb = e.CommandArgument.ToString();                    //传参,传的是gridview这个行的主键
        //this.ClientScript.RegisterStartupScript(this.GetType(), "NotComplete ", "<script> window.open('ReportsSingle/BBF_Reports_Single.aspx?RecNumb=" + RecNumb + "','_blank','location=no,width=1024,height=768,left=50000,top=5000')</script> ");

        this.ClientScript.RegisterStartupScript(this.GetType(), "NotComplete ", "<script> window.open('ReportsSingle/BBF_Reports_Single.aspx?RecNumb=" + RecNumb + "','_blank','width=1024,height=768')</script> ");
       
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值