Sorting child records in a repeater

  • Thread starter Thread starter news.microsoft.com
  • Start date Start date
N

news.microsoft.com

<asp:Repeater id="rptCourseDetail2" runat="server"
datasource='<%#
((DataRowView)Container.DataItem).Row.GetChildRows("CourseDetailRelation")
%>'
EnableViewState="false"
I am having troubles trying to sort child records that appear in a
repeater..... Above is the code that i use for the BINDIng...

.... Before binding i sort the dataset and it sorts correctly... however it
seels that the GetChildRows messes up the sorting routines...

has anyone had this before?

what do i need to do to get this working? Do i need to then sort the results
of GetChildRows? If so how can i sort an datarow array by a specific colomn?

any help would be good..

Darren
http://www.webling.com.au
 
Darren,
If you check out my tutorial on databinding, you should be something helpful
in the sample code. If you open NestedRepeaterWithItemDataBound.aspx and
the codebehind, you'll see an alternative way of databinding a nested
repeater...the code is:

rpt.DataSource =
((DataRowView)e.Item.DataItem).CreateChildView("CustomerOrders")
rpt.DataBind();

CreateChildView returns a DataView, which you can easily filter...

DataView dv =
((DataRowView)e.Item.DataItem).CreateChildView("CustomerOrders");
dv.Sort = "COLUMN ASC";
rpt.DataSource = dv;
rpt.DataBind();

Something like this is probably your best bet
Karl
 
Back
Top