Reputation: 5104
I need to pass parameter from frontend to backend using repeater control My frontend code:
<asp:Repeater ID="Repeater1" runat="server"
onitemdatabound="Repeater1_ItemDataBound"
onitemcommand="Repeater1_ItemCommand">
....
<asp:Button ID="btn_Reply" runat="server" Text="Reply" CommandName="Reply" CommandArgument='<%Eval("id").ToString() %>'/>
....
</asp:Repeater>
Repeater1_ItemCommand event at backend:
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
switch (e.CommandName)
{
case "Reply":
ReplyThread(Convert.ToInt32(e.CommandArgument));
break;
case "Edit":
EditThread(Convert.ToInt32(e.CommandArgument));
break;
case "Delete":
DeleteThread(Convert.ToInt32(e.CommandArgument));
break;
}
}
When click reply button, Why it says e.CommandArgument is not in a correct format., the value in debug model is just a bunch of string: <%Eval("id").ToString() %>, not it's id value.
Any idea?
Upvotes: 0
Views: 3123
Reputation: 3571
Try this instead of your other eval :
<%# Eval("id").ToString() %>
Upvotes: 2