C#
protected void btnSortNames_Click(object sender, EventArgs e)
{
cboNames.DataSource = cboNames.Items.Cast<ListItem>()
.OrderByDescending(o => o.Text)
.ToList();
cboNames.DataBind();
}
protected void btnSortAscending_Click(object sender, EventArgs e)
{
cboNames.DataSource = cboNames.Items.Cast<ListItem>()
.OrderBy(o => o.Text)
.ToList();
cboNames.DataBind();
}
VB.NET
Protected Sub btnSortNames_Click(ByVal sender As Object, ByVal e As EventArgs)
cboNames.DataSource = cboNames.Items.Cast(Of ListItem)().OrderByDescending(Function(o) o.Text).ToList()
cboNames.DataBind()
End Sub
Protected Sub btnSortAscending_Click(ByVal sender As Object, ByVal e As EventArgs)
cboNames.DataSource = cboNames.Items.Cast(Of ListItem)().OrderBy(Function(o) o.Text).ToList()
cboNames.DataBind()
End Sub
No comments:
Post a Comment