asp.net - ASP C# Repeater Button Not Passing String to Method -
i have repeater creates buttons selected items on checkboxlist. checkboxlist list of item codes.
the buttons appear , have item codes text. works.
on click, button should call method using item code of button call method populates data page, not happening. believe button passing empty value.
how repeater button click pass correct value? method works regular text box, have not been able work repeater buttons.
aspx
` <div style="width: 98%; overflow-x: scroll;"> <asp:repeater id="rptitembuttons" runat="server"> <itemtemplate> <asp:button id="btnitembutton" runat="server" text='<%# container.dataitem.tostring() %>' commandargument='<%# container.dataitem.tostring() %>' commandname="repeater_itemcommand" /> </itemtemplate> </asp:repeater> </div>` c#
public void repeater_itemcommand(object sender, commandeventargs e) { saveuserinputsaction(); savedataaction(); lbltestmessage.text = e.commandargument.tostring(); getitemdetails(e.commandargument.tostring()); getcostfactors(e.commandargument.tostring()); }
try setting onitemcommand property of repeater:
aspx:
<asp:repeater id="rptitembuttons" onitemcommand="repeater_itemcommand" runat="server"> <itemtemplate> <asp:button id="btnitembutton" runat="server" text='<%# container.dataitem.tostring() %>' commandargument='<%# container.dataitem.tostring() %>' /> </itemtemplate> </asp:repeater> codebehind:
public void repeater_itemcommand(object sender, repeatercommandeventargs e) { saveuserinputsaction(); savedataaction(); lbltestmessage.text = e.commandargument.tostring(); getitemdetails(e.commandargument.tostring()); getcostfactors(e.commandargument.tostring()); } edit after reviewing code again, noticed specifying commandname="repeater_itemcommand" on button. may work if change oncommand="repeater_itemcommand". kind of specifying event handler on repeater may come down personal preference.
Comments
Post a Comment