Dynamic TextBox DataBinding in a Repeater

Arch4ngel

Senior Contributor
Joined
Mar 22, 2004
Messages
940
Location
Montreal, QC
Here is the situation.

There will be a indefinite number of TextBox that should be DataBinded to a DataTable (DataView... however... all work the same for the render).

Those TextBox are in a repeater control and their ID are generated automaticly. I've managed to access every of them in the ItemDataBound of the repeater. (The repeater have the correct DataSource setted).

I want to be able to DataBind them dynamicly to show the correct value.
I wasn't able do it in the HTML section because those TextBox are Server Control and I'm not used to make it that way.
Please help a poor little programmer in needs :p

Someone have already worked with similar control ?

/* I WORK IN C# BY THE WAY BUT VB.NET IS NO PROB FOR UNDERSTANDING */
 
I'm no guru, but i found an example (which i now dont know where i saved the link) but anyway...

This is my situation and this is what I did:

I have a repeater, with 2 checkboxes,1 radiobutton and 2 textboxes for each row/value that's going to be binded...

I did this whenever a checkbox was clicked:

Code:
 Dim i As Integer
For i = 0 To rpAct22.Items.Count - 1

 ....
   Dim CurrentTextBox As TextBox = CType(rpAct22.Items(i).FindControl("txtNotes22"), WebControls.TextBox)
                Dim InternalNotesBox As TextBox = CType(rpAct22.Items(i).FindControl("txtInternalNotes"), WebControls.TextBox)

 ....

next

I have more controls in there. Not sure if this is what your'e asking about but hope it helps.
 
What I wanted to do... is much more like the DataGrid concept.
C#:
Datagrid1.DataSource = ds;
Datagrid1.DataMember = "YourTable";
Datagrid1.DataBind();

But I would have looked for something that look like this :
C#:
TextBox1.DataSource = ....;
TextBox1.DataMember = ....;
TextBox1.DataValueField = ........;
TextBox1.DataBind();

None of the Textbox property exists. BUT....... DataBind() do exists. Well... do you know how to make this work ????
 
i have to say no, i dont but this guy on 4guysfromrolla is very good at datagrids. Have u tried posting there?
 
I don't think I understand what your asking because this probably isn't the right answer.

When you have a TextBox in a repeater and need to databind it you just click on the DataBinding button in the properties in design view and select "Text" on the left and set the what to data bind it to on the right.

Or in the the hmtl it looks something like this:

<asp:TextBox ID="RepeatedTextBox" Runat="server" Text='"<% DataBinder(Container.DataItem, "Field", {0}) %>"'></asp:TextBox>

Something like that. Can't remember the exacts because my new workplace has forbidden me for installing Visual Studio, so I'm going from memory.

But like I said, I think your looking for something differant; I just don't understand your question.
 
I think it's exactly what I were looking for. I'll try it at work monday and I'll post back if it don't work.

Thank you very much for your time.
 
Back
Top