zoukankan      html  css  js  c++  java
  • 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];
        }

  • 相关阅读:
    Robot Framework的日期处理
    让IIS7和IIS6识别PUT和DELETE请求
    《微服务设计》读书笔记大纲
    规模化微服务——《微服务设计》读书笔记
    Uva 11396 爪分解
    Uva 10765 鸽子和炸弹
    Gym
    Gym
    Gym 101334C 无向仙人掌
    汇编实验十:编写子程序
  • 原文地址:https://www.cnblogs.com/jt880807/p/2630491.html
Copyright © 2011-2022 走看看