Repeater question.

  • Thread starter Thread starter George Ter-Saakov
  • Start date Start date
G

George Ter-Saakov

I am showing a table using repeater control and template for row has a
<asp:TextBox id=txtQuantity runat="server">

Where do i keep the record id in database for that row? Should i create the
hidden field for each row or is there better solution?

so later i could update it in the database.

Here is the code
private void btnUpdate_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
foreach( RepeaterItem objItem in Repeater1.Items )
{
TextBox txtBox = objItem.FindControl("txtQuantity");
//need record id for an update?????
}
}


Thanks.
George.
 
George,

You can always use the DataList control, which a DataKey field built in.
But, the problem with that DataList is that it uses HTML Tables, which I
don't prefer in some cases, as it is hard to control the design. You can
use a HTMLHiddenInput field or i've used an invisible Literal control.

ASPX:
<asp:Literal id=RecordID visible=false ...

Code:
RecordID objItem.FindControl("RecordID").Text

-- Alex Papadimoulis
 
As i found out from MDSN if the DataList is set to RepeatLayout.flow then no
TABLE structure is generated.

So it worked fine form me.

Thanks for the suggestion.
George.
 
Back
Top