Sorry I don't have time today to go back and forth with you to get further
clarification of what you are doing - so I'll go off of what my best guess
is:
I have done apparently similar things but with a DataList (rather than with
a Repeater), and this is what worked for me.
1. I included a <table> in the ItemTemplate (which gets repeated for each
DataRow in the DataTable to which the control is bound at runtime.
2. Within the <table> I have a number of controls all arranged nicely of
course - one of which is a textbox (presumably similary to what you are
doing). Look at the HTML closely:
<asp:TextBox id="txtSequence" style="text-align:'center';" Width="35px"
MaxLength="4" Text='<%# (DataBinder.Eval(Container.DataItem,
"SequenceInCatalog")) %>' runat="server"></asp:TextBox>
Notice this part of the above line:
Text='<%# (DataBinder.Eval(Container.DataItem, "SequenceInCatalog")) %>'
This causes the textbox to get populated at runtime.
So this is what populates the textboxes in my DataList at runtime (and no,
you don't have to know what the names of the textboxes are ahead of time, or
find them, or anything else), and the number of textboxes is determined by
the number of DataRows in the DataTable to which the DataList is bound.
3. Then, when it's time to read the values of the textboxes during a
PostBack (to get the user's newly entered values), I loop through the
Request.Form collection which has everything within the <form> tags in your
aspx page as it was submitted (more than you'll want); and parse out the
control names to find the textboxes and their values.
Perhaps this is all totally off base (I suspect it may be), but I hope it
gives you some ideas for how to proceed.
I'd be interested in knowing why you cannot know the names of your textboxes
ahead of time (apparently they come in from Web.config?). It seems like that
one fact is hanging you up because the Repeater takes the name you supply
and modifies it in order to provide uniqueness when more than one instance
if the control gets rendered. Perhaps you can tell us why you don't bind
your control and prefer instead to loop through the DataTable manually (as
opposed to binding it to the Repeater).
HTH
DK
"MattB" <so********@yahoo.com> wrote in message
news:c5************@ID-86156.news.uni-berlin.de...
This is just a rephrased version of a question I posted earlier. I think
I'm closer now, so it seemed worthy of a new (more specific) post.
In my repeater I'm dynamically creating text boxes, so at compile time I
don't know what text boxes are going to be present at run time. This is
where it seems the FindControl method would be come into play. I loop
through a list of control (all textboxes) names I created on page load and
see if they exist. Unfortunately, even though I see them on the page,
FindControl doesn't come back with anything. I'm guessing it's how I'm
implementing it. Here's some code:
For Each drfields In dtVFields.Rows
Dim strField As String = drfields.Item("Field")
Dim tb As Control = rptVerify.FindControl("txt" & strField)
If Not IsNothing(tb) Then
txtInput = tb.Text
End If
-----------------------
In my test scenario I know I created a textbox with an ID of txtbirth_date
inside the repeater rptVerify, but the code above returns nothing for tb.
If I load the page in a browser and view source, I see my textbox, and it's
id="rptVerify__ctl0_txtbirth_date". So the parent control name is in
there, the id I was expecting is in there, and some other stuff is in there. I
don't even know if that's really relevant. Anyone got any hints to make
this work? Thanks!
Matt