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!

populate repeater with CodeBehind File

Status
Not open for further replies.

ralphtrent

Programmer
Jun 2, 2003
958
US
Hi
I have an aspx file with a CodeBehind file. I will need to use the repeater. When I only had one row to show, I just used the label.text = DataTable.Row[0]["ColumnName"], now that I am using a repeater I can note do that. I have the repeater set up like this:

<asp:Repeater ...>
<itemtemplate>
<asp:label.../>
<asp:label.../>
<asp:label.../>
</itemtemplate>
</asp:repeater>

How can I use the CodeBehind file and the repeater. If I wanted to populate the labels' text property in the aspx file i would use text = <%Container.DataItem("ColumnName")%> but obvioulsy, I can not do that in a CodeBehind.

Let me know if you need more info.

Thanks.

 
You still add the relevant fields that you want to the repeater (e.g <%Container.DataItem("ColumnName")%> ) and then simpyl set the repeaters DataSource in the code behind file and then call the repeater's DataBind method.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
That worked out. Thanks. Now not all of the data will come from a data row, what If I need to manipulate the data and then present out? How would I do that?

Thanks.
 
If you use the ItemDataBound event of the repeater, you can access the row's data that is currently being bound and manipulate it as necessary.


____________________________________________________________

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