asp.net - getting data from repeater controls -


i have repeater contains different controls textbox, dropdownlist,etc... values of these controls populated in itemdatabound of repeater. want values these controls, when click on button. repeater in page has masterpage.

the button code follows

protected void butedit_click(object sender, eventargs e)         {             location loc = new location();             dictionary<string, dictionary<int, string>> ret = dbcommon.fillinterface(loc);             foreach (repeateritem repeated in repedit.items)             {                 dropdownlist drp = (dropdownlist)repeated.findcontrol("drpdown");                 textbox txt = (textbox)repeated.findcontrol("txt");                 checkbox chk = (checkbox)repeated.findcontrol("chk");                 if (drp != null && !string.isnullorempty(drp.attributes["id"]))                 {                     loc.gettype().getproperty(drp.attributes["id"].split('#')[0] + "id").setvalue(loc, int.parse(drp.selectedvalue), null);                 }                 if (txt != null && !string.isnullorempty(txt.attributes["id"]))                 {                     if (txt.attributes["id"].contains("#int"))                     {                         loc.gettype().getproperty(txt.attributes["id"].split('#')[0]).setvalue(loc, int.parse(txt.text), null);                     }                     else if (txt.attributes["id"].contains("#decimal"))                     {                         loc.gettype().getproperty(txt.attributes["id"].split('#')[0]).setvalue(loc, decimal.parse(txt.text), null);                     }                     else                     {                         loc.gettype().getproperty(txt.attributes["id"].split('#')[0]).setvalue(loc, txt.text, null);                     }                 }                 if (chk != null && !string.isnullorempty(chk.attributes["id"]))                 {                     loc.gettype().getproperty(chk.attributes["id"].split('#')[0]).setvalue(loc, chk.checked, null);                  }             }         } 

and aspx

<div class="searchresults">         <asp:repeater id="repedit" runat="server" onitemdatabound="repedit_itemdatabound" viewstatemode="enabled" enableviewstate="true" onitemcommand="repedit_itemcommand">             <itemtemplate>                 <asp:label id="lblname" runat="server" visible="false" viewstatemode="enabled" enableviewstate="true"></asp:label>                 <asp:textbox id="txt" runat="server" visible="false" viewstatemode="enabled" enableviewstate="true"></asp:textbox>                 <asp:checkbox id="chk" runat="server" visible="false" viewstatemode="enabled" enableviewstate="true"/>                 <asp:dropdownlist id="drpdown" runat="server" visible="false" enableviewstate="true"></asp:dropdownlist>             </itemtemplate>             <separatortemplate>                 <br />             </separatortemplate>             <footertemplate>                 <asp:button runat="server" id="butedit" visible="false" text="update" commandargument="editcomm" />             </footertemplate>         </asp:repeater>      </div> 

i have used item.findcontrol() method values. need value inside itemcommand function.

public void repedit_itemcommand(object source, repeatercommandeventargs e) {     txtfield = (textbox)e.item.findcontrol("txt");     txtfield.text; } 

like can other values repeater. worked me, please try this.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -