Reputation: 2187
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" OnCommand= "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
Upvotes: 0
Views: 1136
Reputation: 67195
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.
Upvotes: 0
Reputation: 17957
You're setting the CommandArgument in your aspx, but checking the CommandName in your event handler.
Upvotes: 0
Reputation: 161773
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.
Upvotes: 1