c# - Command Argument not working link button -
i have link button , set of records. when link button of specific record clicked, want id of record passed code behind. code have used:
<asp:linkbutton id="likes" runat="server" oncommand="linkbutton1_click" commandargument='<%#eval("datarow["id"]") %>' commandname="like"> click</asp:linkbutton>
and in cs file have used:
protected void linkbutton1_click(object sender, commandeventargs e) { int x = int32.parse(e.commandargument.tostring()); }
but command argument null here. can please me?
you handle wrong event. think linkbutton inside control @greg84 said, example, handle event itemdatabound of datagrid or repeater .
protected void control_itemdatabound(object sender, controlitemeventargs e) { linkbutton likes = (linkbutton)e.item.findcontro("likes"); // write code here handle click // ... }
Comments
Post a Comment