CommandArgument 传递多个参数(以2个为例)

 <asp:GridView ID="GVSecondType" runat="server" AutoGenerateColumns="False" Style="position: relative" Width="100%" CellPadding="4" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" AllowPaging="True" OnPageIndexChanging="GVSecondType_PageIndexChanging" OnRowCommand="GVSecondType_RowCommand">

        <Columns>

            <asp:TemplateField HeaderText="所属一级分类">

                <EditItemTemplate>

                    <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>

                </EditItemTemplate>

                <ItemTemplate>

                    <asp:Label ID="lblName" runat="server" Style="position: relative" Text='<%#Eval("Parent_TypeName1") %>'></asp:Label>

                </ItemTemplate>

            </asp:TemplateField>

            <asp:BoundField DataField="Id" HeaderText="分类ID" />

            <asp:BoundField DataField="Type_Name" HeaderText="分类名" />

             <asp:BoundField DataField="Parent_Id" HeaderText="所属父类" />

            <asp:BoundField DataField="Type_AddTime" HeaderText="添加时间" />

            <asp:TemplateField HeaderText="编 辑">

                <EditItemTemplate>

                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

                </EditItemTemplate>

                <ItemTemplate>

                   <div style="width:70px;line-height:20px; cursor:pointer;background-color:#CCCCCC; border:solid 1px #000000; "><a  style="text-decoration:none; cursor:pointer" href='ModifySecondType.aspx?TypeId=<%#Eval("Id") %>'>修改</a></div>

                </ItemTemplate>

            </asp:TemplateField>

            <asp:TemplateField HeaderText="删 除">

                <EditItemTemplate>

                    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

                </EditItemTemplate>

                <ItemTemplate>

                    <div onmouseover="javascript:this.style.cursor='hand'" style="width:70px; line-height:20px;background-color:#CCCCCC;border:solid 1px #000000;"> <asp:LinkButton ID="LinkButton1" CommandName="del" CommandArgument='<%# Eval("Parent_Id")+","+Eval("Id")  %>'  runat="server">删除</asp:LinkButton></div>

                </ItemTemplate>

            </asp:TemplateField>

           

        </Columns>

        <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />

        <RowStyle BackColor="White" ForeColor="#003399" />

        <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />

        <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />

        <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />

    </asp:GridView> 



protected void GVSecondType_RowCommand(object sender, GridViewCommandEventArgs e)

    {

        string cmdName = e.CommandName;

        if (cmdName == "del")

        {

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



            int Parent_Id = Convert.ToInt32(estr[0]);

            int TypeId = Convert.ToInt32(estr[1]);

            bool flag = YHTBLL.Second_TypeManage.DelTypeById(Parent_Id, TypeId);

            if (flag)

            {

                this.Literal1.Text = "删 除 成 功";

                bind();

            }



            else

            {

                this.Literal1.Text = "删 除失 败";

                bind();

            }



        }

     

    }





本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/y_h_t/archive/2009/11/18/4827980.aspx

你可能感兴趣的:(command)