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

Bind data in a repeater to an editable textbox 2

Status
Not open for further replies.

belle9

Programmer
Nov 3, 2004
87
US
Here's my repeater:

Code:
   <asp:repeater id=rptDiet runat="server">
					<ItemTemplate>
						<asp:Textbox ID="txtDiet" Runat="server" Visible="True">
							<%#Container.Dataitem("Data")%>
						</asp:TextBox>
					
					</ItemTemplate>
				</asp:repeater>

I'm getting an error with the textbox, saying:
"System.Web.HttpException: 'TextBox' cannot have children of type 'DataBoundLiteralControl'."

I'd like to pull the data from the table and display it in the textbox, allowing the user to update it. The data is multiple rows returned.
 
i believe you'll have to use a datalist for this...repeaters are not updateable as far as i know...

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
Hmmm, get the same error for a datalist:
"System.Web.HttpException: 'TextBox' cannot have children of type 'DataBoundLiteralControl'"

Code:
<asp:datalist id="dlDiet" runat="server">
														<ItemTemplate>
															<asp:TextBox ID="txtDiet2" Runat="server" Visible="True" >
																<%#Container.Dataitem("Data")%>
															</asp:TextBox>
														</ItemTemplate>
													</asp:datalist>
 
Code:
<ItemTemplate>
<asp:TextBox ID="txtDiet" Runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Data")%>' >
</asp:TextBox><br />
</ItemTemplate>
 
I think you have to set the Text property = to the data...

Code:
<asp:datalist id="dlDiet" runat="server">
<ItemTemplate>
<asp:TextBox ID="txtDiet2" Runat="server" Visible="True" Text='<%#Container.Dataitem("Data")%>' >                                             </asp:TextBox>                                         </ItemTemplate>                                             </asp:datalist>

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top