0
votes

I am filling up a liwith LinkButton's. But each LinkButton should have commandArgument with a ID. And when doing an oncommand I'm not getting it. Code:

<% foreach (be.absi.ibge.data.Informer inform in this.GetIncludedItems(tax.id, true))
  { %>
  <li>
    <asp:LinkButton OnCommand="myMethod_Click" CommandName="cmdName" CommandArgument="<%= inform.id%>" >
      <%= inform.content.title%>
    </asp:LinkButton>
  </li>
<% } %>

But in the method myMethod_ClickI am getting <%= inform.id%> for the argument cmdName.

the oncommand method:

protected void myMethod_Click(object sender, CommandEventArgs e)
{
  Session["sessionTest"] = e.CommandArgument.ToString();
}

Any solutions?

EDIT: People, I can't run this code because there is no runat="server". If I add this then <%%>doesn't work. So i'm trying to convert this to a repeater. Thanks for replies.

2

2 Answers

1
votes

Thats because your formatting is wrong. use ' instead of "

<asp:LinkButton OnCommand="myMethod_Click" CommandName="cmdName" CommandArgument='<%= inform.id%>' >
      <%= inform.content.title%>
    </asp:LinkButton>
0
votes

Would you please try below way, thanks for your time.

<% foreach (be.absi.ibge.data.Informer inform in this.GetIncludedItems(tax.id, true))
  { %>
    <li>
      <asp:LinkButton OnCommand="myMethod_Click" CommandName="cmdName"
        CommandArgument='<%= inform.id%>' Text='<%= inform.content.title %>' >            
      </asp:LinkButton>
    </li>
<% } %>