asp.net - Can't call a function or access a controller which is used in a repeater, in codebehinde -


i've searched internet , didn't find working answer question.

the question when use text-box , button in asp:repeater c# aspx website update column of sql server table, can't access textbox , button in code-behind (aspx.cs) page. i've find way "show" controllers (the text-box , button) in asp:repeater in link below, can't use update database of website.

can't find control within asp.net repeater?

i'd glad if know how solve problem, reply this.

here sample code of demonstrating problem:

aspx page

                        <asp:repeater runat="server" id="commentha" >                              <itemtemplate>                                 <div id="comment list" style="direction: rtl; font-family: '2  nazanin','adobe arabic'; font-size: large;">                                         <div id="replys">                                             <%--asp label showing replys comment--%>                                         </div>                                         <div id="replyto">                                             <div id="rt_text">reply</div>                                             <div id="replytothis">                                                 <asp:textbox runat="server" id="reply" maxlength="119"></asp:textbox>                                                 <asp:button runat="server"  id="sendit" text="send" />                                             </div>                                         </div>                                     </div>                                 </div>                             </itemtemplate>                         </asp:repeater> 

the "reply" textbox , "sendit" buttons controllers talking about.

and sql table has column:

replyto nvarchar(120)

i trying make "reply comment" function, similar facebook's "reply" button commenting section.

you need events associated repeater. on itemcommand. below snippet allow grab textbox.

added commandname button allows assign requests made specific actions using itemcommand event handler.

<asp:button id="sendit" runat="server" width="80px" text="send" commandname="send"/> 

add event handler. when button clicked apply logic within if statement. can grab controls within row using findcontrol. access them object variable. in case txt.

 protected void commentha_itemcommand(object source, repeatercommandeventargs e)     {             if (e.commandname == "send")                {                    textbox txt = e.item.findcontrol("reply") textbox ;                  string replytext = txt.text;                   // sql                 }     } 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -