LinkButton的onComand

后台程序就是这样,你需要将gridview绑定的函数独立出来 如gridbind();
在执行linkbutton click事件后再调用一次 gridbind(); 
你先单独看看是否取到了e.commandArgument 
commandArgument 也是需要绑定的。在前台中 gridview是模板化的,并绑定commandArgument 
你在后台才能取到他的值。
----------------------------------------------------------------------------------------------------------
Gridview 获取行号或者此行某一列的数据  跳转到各自不同的页面
位置:把一个linkbutton先转化成模板  
<asp:TemplateField HeaderText="link" ShowHeader="False">
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" 
                        CommandName="button" Text="Button"     CommandArgument='<%# Container.DataItemIndex %>' 
                        οnclick="LinkButton1_Click"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
在Gridview_RowCommand 或者 RowDataBound函数中 写入
  int  j = Convert.ToInt32(e.CommandArgument);
          
   LinkButton lb = (LinkButton)GridView1.Rows[j].FindControl("LinkButton1");
            if (j == 0)
                lb.PostBackUrl = "login.aspx";
            if (j == 1)
                lb.PostBackUrl = "Register.aspx";
       根据不同行号 点击linkbutton跳转到不同的页面
 
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>LinkButton Command Event Example</title>
<script language="C#" runat="server">

      void LinkButton_Command(Object sender, CommandEventArgs e) 
      {
         Label1.Text = "You chose: " + e.CommandName + " Item " + e.CommandArgument;
      }

   </script>

</head>
<body>

   <form id="form1" runat="server">

      <h3>LinkButton Command Event Example</h3>

      <asp:LinkButton id="LinkButton1" 
           Text="Order Item 10001"
           CommandName="Order" 
           CommandArgument="10001" 
           OnCommand="LinkButton_Command" 
           runat="server"/>

      <br />

      <asp:LinkButton id="LinkButton2" 
           Text="Order Item 10002"
           CommandName="Order" 
           CommandArgument="10002" 
           OnCommand="LinkButton_Command" 
           Runat="server"/>

      <br />
      <br />

      <asp:Label id="Label1" runat="server"/>

   </form>

</body>
</html>
 方法1、ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(UpdatePanel), "alert", "alert('退办成功');window.location.href ='AgencyDocumentALLList.aspx';", true);
方法2、ClientScript.RegisterStartupScript(Page.GetType(), "myalert", "alert('退办成功');window.location.href ='AgencyDocumentALLList.aspx';", true);
方法3、ClientScript.RegisterStartupScript(Page.GetType(), "myalert", "<Script language='JavaScript'>alert('退办成功');window.location.href ='AgencyDocumentALLList.aspx'</Script>");


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值