开发者

i don't know how to work with command argument in asp.net

i'm tryng to pass a parameter with command argument with a link button but the result i get is always "".

this is in my aspx page:

<%
LinkButton1.CommandArgument = "abcdef";                                 
%>
<asp:LinkButton ID="LinkButton1" runat="server" OnCom开发者_如何学运维mand= "LinkButton1_Click">

and in my aspx.cs i have:

protected void LinkButton1_Click(object sender,CommandEventArgs ee)
{
    String id = ee.CommandName.ToString();
}

the id is always "" after i press the linkbutton.

would appreciate if someone could help me. thanks


Try something like this:

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

From the example at LinkButton.CommandArgument Property.


I'm not at my dev machine but it would be more like this:

<asp:LinkButton ID="LinkButton1" runat="server"
    CommandArgument="abcdef" OnCommand="LinkButton1_Click" >

And then check CommandArgument in your code.


You're setting the CommandArgument in your aspx, but checking the CommandName in your event handler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜