jeffchs Posted October 6, 2003 Posted October 6, 2003 I am hving trouble using a textbox in a repeater. I am able to find the textbox in each repeater item but cannot access the Text attribute of the textbox or the label for that matter. My code is as follows. Any help would be greatly appreciated. <script> void SubmitAnswers(object o, EventArgs e) { TextBox answer; Label answerNumber; foreach(RepeaterItem ri in questionsRpt.Items) { if(ri.ItemType == ListItemType.Item || ri.ItemType == ListItemType.AlternatingItem) { answerNumber = (Label)ri.FindControl("answerNumber"); Response.Write(answerNumber.ID); Response.Write(answerNumber.Text ); // no output here answer = (TextBox)ri.FindControl("answer"); Response.Write(answer.ID); Response.Write(answer.Text ); // no output here } } } </script> <asp:repeater ID="questionsRpt" runat="server"> <headertemplate> <table class="contenttext"> </headertemplate> <itemtemplate> <tr><td><asp:label ID="answerNumber" runat="server"><%# DataBinder.Eval(Container.DataItem, "number")%></asp:label>. </td><td><%# DataBinder.Eval(Container.DataItem, "question")%></td></tr> <tr><td></td><td><asp:textbox runat="server" MaxLength="1000" ID="answer" /></td></tr> </itemtemplate> <footertemplate> <tr><td></td><td align="right"><asp:button Text="Submit" runat="server" OnClick="SubmitAnswers" /></td></tr> </table> </footertemplate> </asp:repeater> Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.