CommandArgument Pass multiple arguments (in 2 cases)

Source: Internet
Author: User
Tags add time

<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= "Subordinate Classification" >
<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= "Category ID"/>
<asp:boundfield datafield= "type_name" headertext= "classification name"/>
<asp:boundfield datafield= "parent_id" headertext= "parent class"/>
<asp:boundfield datafield= "Type_addtime" headertext= "Add Time"/>
<asp:templatefield headertext= "Edit" >
<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")%> ' > Modify </a></div>
</ItemTemplate>
</asp:TemplateField>
<asp:templatefield headertext= "Delete" >
<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" > Delete </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"/>
</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 = "Delete succeeded";
                bind ();
           }

Else
{
This. Literal1.text = "Delete Failed";
Bind ();
}

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.