• gridview 中使用linkbutton 实现多值传递


    选课系统中,同时选中 书号,和教师的ID 号:

    a.aspx 中

    <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label

     <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>

    <asp:GridView ID="GridView1" runat="server" 
                    DataKeyNames="cid" CellPadding="4" ForeColor="#333333" GridLines="None"
                  
                    Width="449px"  >
                    <RowStyle BackColor="#EFF3FB" />
                    <Columns>
                        <asp:BoundField DataField="cid" HeaderText="课程号" ReadOnly="True"
                            SortExpression="cid" />
                        <asp:BoundField DataField="cname" HeaderText="课程名" SortExpression="cname" />
                        <asp:BoundField DataField="credit" HeaderText="学分"
                            SortExpression="credit" />
                        <asp:BoundField DataField="hour" HeaderText="课时" SortExpression="hour" />
                        <asp:BoundField DataField="tid" HeaderText="教师名" SortExpression="" />
                        <asp:TemplateField><ItemTemplate>  
                       
     
                        <asp:LinkButton ID="LinkButton1" runat="server" OnCommand="click" CommandArgument='<%#eval_r("cid")+","+eval_r("tid")%>'>
                            选课</asp:LinkButton>
                       </ItemTemplate></asp:TemplateField>
                    </Columns>
               
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <EditRowStyle BackColor="#2461BF" />
                    <AlternatingRowStyle BackColor="White" />
               
                </asp:GridView>
              

    a.aspx.cs 中收取参数的过程:

    protected void click(object sender, CommandEventArgs e)
        {
         //  int id = int.Parse((string)e.CommandArgument);
       //    string cid = id.ToString().Trim();

           string[] str = e.CommandArgument.ToString().Split(',');

        //   model.id = Convert.ToInt32(str[1]);

           

          //  this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert(' "+cid+"')</script>");

           Label2.Text = str[0];
           Label3.Text = str[1];
        }

  • 相关阅读:
    模拟Spring创建Bean和dom4j读取xml文件(视频学习传智播客Spring2.503)
    三种实例化Bean的方式
    junit4测试用例
    Spring注解方式管理事务以及事务传播行为Propagation(视频笔记23)
    Hibernate注解Annotation
    SSH框架整合(二)
    Oracle命令行中启动服务创建用户,权限,密码丢失
    Spring事务管理
    嚯嚯~~第一篇
    fedora下配置dhcpv6服务器
  • 原文地址:https://www.cnblogs.com/jt880807/p/2630491.html
Copyright © 2020-2023  润新知