How to access a named table from a repeater control with the eval method

G

Georg Mayer

Hi,
In my DataSet, which is bound to a repeater, I have two tables: item
and child:
ds = new DataSet();
itemadapter.Fill(ds, "item");
childadapter.Fill(ds, "child");

How do I access e.g. the item table and the colums in it from my
itemtemplate of the repeater control?

I'v tried the following code which doesn't work:
<asp:Repeater ID="Repeater1" Runat="server" >
<ItemTemplate>
<td>
<asp:Label Runat="server" Text='<%#
DataBinder.Eval(Container.DataItem,
"Tables[item].DefaultView.[0].Price") %>' ></asp:Label>
</ItemTemplate>
</asp:Repeater>

I get an exception there: "DataBinding: 'System.Data.DataRowView' does
not contain a property with the name 'Tables'."

Can anyone tell how I could get the information from that "item"
table?

Thanx

Georg
 
S

Scott Allen

Hi Geog:

One way to do this would be to make the DataSet a protected field in
your code behind (the base class).

Then you will be able to do something like:

<%# DataBinder.Eval(myDataSet, "Tables[1].DefaultView[0][0]") %>

The trick will be in knowing what row you need to access, but perhaps
you already have that setup to work.

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top