Light Kun
Light Kun

Reputation: 147

Repeater Order by Name in ASP.net

how to set a repeater that will order by Name A-Z?

Upvotes: 0

Views: 3108

Answers (2)

Josh
Josh

Reputation: 44906

The repeater will simply enumerate the datasource assigned to it. If you want to order the display of the repeater you need to order the underyling datasource.

var orderedByNameList = People.OrderBy(p => p.Name);

rptPeople.DataSource = orderedByNameList;
rptPeople.DataBind();

Upvotes: 4

Jack Marchetti
Jack Marchetti

Reputation: 15754

Sort the datasource Ascending would be the easiest way.

Upvotes: 0

Related Questions