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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp:textbox in a asp:repeater 1

Status
Not open for further replies.

valed74

Technical User
Dec 14, 2004
5
IT
Hi,
I have an asp:textbox conteined in a asp:repeater that take its value from a db's table:
<code>
<ItemTemplate>
.... <asp:TextBox ID="Textbox1" Runat=server Text='<%#Container.DataItem("value")%>'>
......
</ItemTemplate>
</code>
The idea is that the client sees the value conteined and if he wants to cange it he can do it by typing the new value into the textbox first and then pushing the button "updete".
The problem is that when it goes into the Sub UpDate by pushing the button:
<code>
Sub UpDate(sender As Object, e As EventArgs)
.....
Dim address
address= Textbox1.text
'"tumtumtum"customers.ItemTemplate()
......
End Sub
</code>
it gives me the following error:
"Object reference not set to an instance of an object.
....
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
...
Line 52: address= Textbox1.text
......."

It seems that if I want to update the value by typing it into an asp:textbox conteined in an asp:repeater I have not to write address=Textbox1.text becouse the asp:textbox is conteined in en asp:Repeater. Is it right?
Can sombody tell me how can write it and if this way is the correct way to update values?

thanks a lot,
Valerio
 
There are a few ways to do this. The most common way I find is that the FindControl method is used to located the text in the TextBox (remember the textbox is created in each ro so if you look at the HTML in View Source there will probably won't be a textbox created with the ID of TextBox1).

If you are creating an editable web grid, I find the following article very useful to follow:


--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top