get textbox value in user control??

D

DaveF

I have a textbox in a user control that a put in a aspx page. How do I get a
referance to that textbox from my aspx page?
 
C

Curt_C [MVP]

foreach (RepeaterItem ri in this.rptrCustomFields.Items)

{

TextBox txtRepeater = (TextBox)ri.FindControl("txtRepeater");

}
 
K

Karl Seguin

He didn't say anything about repeaters...though obviously the same could be
applied to a user control (though it's a little different) :p

Karl
 
Joined
Jul 6, 2007
Messages
2
Reaction score
0
Question about the repeater

I have a radiobuttonlist I'm repeating and I need to know if I can get the values they select (1-10 for a survey)? Using c# looks like this:

Code:
    protected void submit_Click(object sender, EventArgs e)
    {
        foreach (RepeaterItem riRating in this.Questions.Items)
        {
            RadioButtonList rating = (RadioButtonList)riRating.FindControl("rbList");
            Label1.Text += rating.SelectedIndex.ToString() + "</br>";
        }
        
    }

ASP:

Code:
 <asp:Repeater ID ="Questions" runat="server">
            <ItemTemplate>
                <table>
                    <tr style ="border-bottom-color:black">
                        <td colspan="3" style="height: 20px">
                            <asp:Label ID="Label1" runat="server"></asp:Label>
                            <b><%# DataBinder.Eval(Container.DataItem, "Question")%>
                               </b>
                            </td>
                    </tr>
                    <tr>
                        <td style="width: 63px; height: 20px">
                            Not Good</td>
                        <td style="width: 22px; height: 20px">
                            <asp:RadioButtonList ID="rbList" runat="server" AutoPostBack="False" BorderStyle="none"
                                Height="34px" 
                                RepeatDirection="Horizontal" Width="44px ">
                                <asp:ListItem Value="1"></asp:ListItem>
                                <asp:ListItem Value="2"></asp:ListItem>
                                <asp:ListItem Value="3"></asp:ListItem>
                                <asp:ListItem Value="4"></asp:ListItem>
                                <asp:ListItem Value="5"></asp:ListItem>
                                <asp:ListItem Value="6"></asp:ListItem>
                                <asp:ListItem Value="7"></asp:ListItem>
                                <asp:ListItem Value="8"></asp:ListItem>
                                <asp:ListItem Value="9"></asp:ListItem>
                                <asp:ListItem Value="10"></asp:ListItem>
                            </asp:RadioButtonList></td>
                        <td style="width: 45px; height: 20px">
                            Excellent</td><br />
                        <td style="width: 45px; height: 20px"><br />
                        <asp:Label ID="lblAnswer" runat="server" Visible="true" Text=""></asp:Label></td>
                    </tr>
                </table>
            </ItemTemplate>
        </asp:Repeater>
    &nbsp;<asp:Button ID="submit" Text="Submit" runat="server" OnClick="submit_Click"/>
    <br />
    <asp:Label ID="Label1" runat="server"></asp:Label>


rbList is the ID for the actual radiobuttonlist and not the repeater. Any ideas? Help would be greatly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top