c# - How to make button visible inside repeater? -


here have kept 2 button(btnhide , btnunhide) , label inside repeater , have made button btnunhide invisible initially. want press button btnhide btnunhide invisible intially should visible. solution great help.

html used

  <asp:repeater id="repeater1" runat="server" onitemcommand="repeater1_itemcommand" >         <itemtemplate>               <asp:label id="label1" runat="server" text="label"></asp:label>                <asp:button id="btn" commandname="h" runat="server" text="hide" />             <asp:button id="btnhide" visible="false" runat="server" text="unhide" />               </itemtemplate>     </asp:repeater> 

code behind

protected void repeater1_itemcommand(object source, repeatercommandeventargs e) {     if (e.commandname == "h")     {       } } 

you can achieve single button changing text hide/unhide , functionality required checking text property of button.

protected void repeater1_itemcommand(object source, repeatercommandeventargs e) {     if (e.commandname == "h")     {         button btn = (button)(e.commandsource);         if(btn.text == "hide")         {            btn.text = "unhide";            //do additional work here, when unhiding.         }         else         {            btn.text = "hide";            //do additional work here, when hiding.         }      } } 

i hope, helps. thanks


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -