Sorting child records in a repeater

  • Thread starter news.microsoft.com
  • 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
 
K

Karl Seguin

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
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top