1

I wonder if someone could assist please....I've been following various tutorials (on here and on the MSDN site) and I've ended up completely confusing myself!

I've got a dataset which looks something like the following:

id |  descipt  |  letter
1  |  ADR      |  A
2  |  Agril    |  A
3  |  Banking  |  B
4  |  Benefit  |  B

Going up alphabetically to Z.

What I'm trying to achieve is build a nested repeater up that when finished would look like:

A
ADR
Agril

B
Banking
Benefit

This is what I've done so far but it just doesn't work (currently my error is DataBinding: 'System.Data.DataRow' does not contain a property with the name 'descript'.). I just don't understand enough to sensibly work this out. My repeater looks like:

<asp:Repeater ID="rptParentAD" runat="server">
  <ItemTemplate>
    <%# DataBinder.Eval(Container.DataItem, "letter") %><br />
        <asp:Repeater Id="rptChildAD" runat="server" DataSource='<%# ((DataRowView)Container.DataItem).Row.GetChildRows("myRelation") %>'>
          <ItemTemplate>
              <%# DataBinder.Eval(Container.DataItem, "descript") %><br />
          </ItemTemplate>
        </asp:Repeater>
   </ItemTemplate>
 </asp:Repeater>

And my code behind is like this:

        dtCourses = myDataSet.Tables[1];
        drFilter = dtCourses.Select(zAtoD); //Apply the filter to the table to get interests beginning with A - D
        dtLettersAD = drFilter.CopyToDataTable().DefaultView.ToTable(true, "letter"); //Convert this filtered list back to a datatable but now it returns the distinct letters
        dtCourses2 = drFilter.CopyToDataTable().DefaultView.ToTable();

        dsParent2Child.Tables.Add(dtLettersAD);
        dsParent2Child.Tables.Add(dtCourses2);

        dsParent2Child.Relations.Add("myRelation", dtLettersAD.Columns["letter"], dtCourses2.Columns["letter"]);

        rptParentAD.DataSource = dtLettersAD;
        rptParentAD.DataBind();

Basically I've just completely confused myself. Could anyone spare a few minutes to help please?

Thanks, Craig

SxChoc
  • 619
  • 3
  • 10
  • 26

0 Answers0