"Andy" <An**@discussio ns.microsoft.co m> wrote in message
news:80******** *************** ***********@mic rosoft.com...
I am attempting to print out a table using a repeater in which one field
is updatable. Basically you would have a table of x number of rows and y
number of columns. However: only one field in each row will be updatable. My
thought was to build a repeater and then one of the <ItemTemplate > would
be a textbox where the user can update the values in each.
How would I go about in the code-behind to reference each textbox? My
texbox definintion is: <asp:Textbox ID="cID"......
Is an array created and I loop through the array? Just not sure how to
handle this.
For setting the value, use the ItemDataBound event:
private void Repeater1_ItemD ataBound(object sender,
System.Web.UI.W ebControls.Repe aterItemEventAr gs e)
{
if ( e.Item.ItemType == ListItemType.It em )
{
TextBox myTextBox = (TextBox)e.Item .FindControl("T extBoxName");
myTextBox.Text = "Some Text"; // use "e.Item.DataIte m" to get data from
a bound data source.
}
}
To read the user's changes:
foreach ( RepeaterItem item in Repeater1.Items )
{
if ( item.ItemType == ListItemType.It em)
{
TextBox myTextBox = (TextBox)e.Item .FindControl("T extBoxName");
// do something with "myTextBox.Text "
}
}