GrantBailey
asked on
find control in repeater
Hello All,
I have a page with the wizard control. In one of the steps I have repeater1 and each field has a textbox called questionExpained. I need to loop through the repeater and add the textbox text to the database. I'm having issues finding the textbox. Here is the code.
I have a page with the wizard control. In one of the steps I have repeater1 and each field has a textbox called questionExpained. I need to loop through the repeater and add the textbox text to the database. I'm having issues finding the textbox. Here is the code.
<asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0" DisplaySideBar="False">
<WizardSteps>
<asp:WizardStep ID="WizardStep1" runat="server" title="Step 1">
<asp:Repeater ID="page1Repeater" runat="server" >
<ItemTemplate>
<asp:TextBox ID="questionExplained" runat="server" Height="72px" TextMode="MultiLine" Width="453px"></asp:TextBox>
</ItemTemplate>
</asp:Repeater>
</asp:WizardStep>
<asp:WizardStep ID="WizardStep2" runat="server" title="Step 2">
and so on....
VB CODE
For Each item As RepeaterItem In page1Repeater.Items
Dim b As TextBox = TryCast(item.FindControl("question1Explained"), TextBox)
Response.Write(b.Text + "<br>")
Next
' This loops but does not return any values.
ASKER
Hi guru_sami,
I do not know how to properly user the debugger. I can set the breakpoints but I do not know how to interpret the results of the debugger.
I do not know how to properly user the debugger. I can set the breakpoints but I do not know how to interpret the results of the debugger.
Say you set the breakpoint on statement like below:
For Each item As RepeaterItem In page1Repeater.Items
Dim b As TextBox = TryCast(item.FindControl(" question1E xplained") , TextBox)
breakpoin here---> Response.Write(b.Text + "<br>")
Next
Then upon debugging:
1: does your execution stop at breakpoint statement?
2: If it does, it means you have items for repeater to display and if Not then something going on
3: Once it stops at bp statement, you can mouse-over the Items and dig into its Count property to see how many items.
For Each item As RepeaterItem In page1Repeater.Items
Dim b As TextBox = TryCast(item.FindControl("
breakpoin here---> Response.Write(b.Text + "<br>")
Next
Then upon debugging:
1: does your execution stop at breakpoint statement?
2: If it does, it means you have items for repeater to display and if Not then something going on
3: Once it stops at bp statement, you can mouse-over the Items and dig into its Count property to see how many items.
ASKER
guru_sami,
Ok, in the debugging the repeater is showing an item count of 8 which is the number of results bound to the repeater.
Ok, in the debugging the repeater is showing an item count of 8 which is the number of results bound to the repeater.
hmmm so when you say trouble over finding textbox...do you mean b is null or ..?
So how about the Text when you hover over b.Text while debugging...what is the value for that?
So how about the Text when you hover over b.Text while debugging...what is the value for that?
ASKER
The value for b.text is showing as ""
hmmm... repeater has items but tb is not retaining value...not sure exactly what's happening....
when exactly your code block executed and how's your repeater databound?
Do you have code snippet which I can use to replicate the issue?
when exactly your code block executed and how's your repeater databound?
Do you have code snippet which I can use to replicate the issue?
ASKER
I set up a page which show the code summary. Please take a look.
http://www.beachmerchant.com/AppTesting/repeaterCode.htm
http://www.beachmerchant.com/AppTesting/repeaterCode.htm
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
guru_sami is the best!
ASKER
Well, I guess that show my inexperience in dotNet. Thanks so much guru_sami for your patience and help in solving my issue.
What a wonderful world this would be if everyone help their fellow man as they do here at experts exchange.
What a wonderful world this would be if everyone help their fellow man as they do here at experts exchange.
Make sure your repeater has data items to display.