?
Solved

find control in repeater

Posted on 2010-09-09
11
Medium Priority
?
479 Views
Last Modified: 2012-06-27
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.

<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.

Open in new window

0
Comment
Question by:GrantBailey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 41

Expert Comment

by:guru_sami
ID: 33637824
did you set breakpoint and see what value are you getting for "page1Repeater.Items"?
Make sure your repeater has data items to display.
0
 

Author Comment

by:GrantBailey
ID: 33640110
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.
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 33640165
Say you set the breakpoint on statement like below:

For Each item As RepeaterItem In page1Repeater.Items
            Dim b As TextBox = TryCast(item.FindControl("question1Explained"), 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.

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:GrantBailey
ID: 33640363
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.
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 33641099
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?
0
 

Author Comment

by:GrantBailey
ID: 33641198
The value for b.text is showing as "" 
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 33641975
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?
0
 

Author Comment

by:GrantBailey
ID: 33642278
I set up a page which show the code summary. Please take a look.
http://www.beachmerchant.com/AppTesting/repeaterCode.htm
0
 
LVL 41

Accepted Solution

by:
guru_sami earned 2000 total points
ID: 33642411
Ok the repeater is databound on postback so the TB is losing the value..so modify your Page_Load like below:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 If Not Page.IsPostBack Then
    BindPage()
End If
End Sub
0
 

Author Closing Comment

by:GrantBailey
ID: 33648332
guru_sami is the best!
0
 

Author Comment

by:GrantBailey
ID: 33648334
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.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question