Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Repeater Control not submitting properly

Status
Not open for further replies.

Custom24

Programmer
Nov 27, 2001
591
GB
Hi
I am missing something

On a web form I have a repeater control. I've set it up to be data bound to 2 columns from my data source, to a label and a text box respectively, and at run time under page load, I do the data binding.

There is a submit button, and when the user presses this, I want the new values of the text boxes to be passed to a procedure. The problem is that the original values are being passed, even though in the repeater 'HTML', viewstate is turned on.

A seperate text box on the form is behaving normally.

Anyone any ideas

Here is the HTML bit

<asp:Repeater id=&quot;repPartsUsed&quot; runat=&quot;server&quot;>
<ItemTemplate>
</ItemTemplate>
<ItemTemplate>
<li>
<asp:Label Runat=server text='<%#dr(&quot;Info&quot;)%>' EnableViewState=True>
</asp:Label>
<asp:TextBox Runat=server Text='<%#dr(&quot;Parts_Used&quot;)%>' EnableViewState=True>
</asp:TextBox>
</li>
</ItemTemplate>
</asp:Repeater>

Here is the bit which binds it on page load


Dim cmdGetPartsUsed As New OleDbCommand()
cmdGetPartsUsed.Connection = Conn
cmdGetPartsUsed.CommandType = CommandType.Text
cmdGetPartsUsed.CommandText = &quot;Select * from v_parts_used_by_entry where entry_id = &quot; & Request.QueryString(&quot;EntryID&quot;)

'Stop
Conn.Open()
dr = cmdGetPartsUsed.ExecuteReader
repPartsUsed.DataSource = dr
repPartsUsed.DataBind()
dr.Close()
Conn.Close()

And here is the bit where I try to get the new values

Dim repItem As RepeaterItem
For Each repItem In repPartsUsed.Items
Dim thisLabel As Label
Dim thisTextBox As TextBox
thisLabel = CType(repItem.Controls(1), Label)
thisTextBox = CType(repItem.Controls(3), TextBox)
Debug.WriteLine(&quot;Part Id = &quot; & thisLabel.Text & vbTab & &quot;Quantity = &quot; & thisTextBox.Text)
Next
Debug.WriteLine(&quot;The test text box = &quot; & txtTest.Text)

The txtTest works correctly, but thisTextBox prints the old values

Thanks in advance
Mark
 
I am such a muppet. I forgot that the data bind should not be done in page_load when the form is not being posted back. The addition of

If not page.ispostback

solved the problem
Thanks anyway
Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top