• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 413
  • Last Modified:

Sort by column name in Listview

How can I implement sorting in a asp.net listview control in which the user can choose a column name from a dropdown of column names and asc/desc from a drop down too.

0
TrialUser
Asked:
TrialUser
  • 2
2 Solutions
 
anarki_jimbelCommented:
Please check the link below, hope it may help:

http://www.4guysfromrolla.com/articles/011608-1.aspx

If this does not help - tell what control you are using. Why do you want to sort using dropdowns?

0
 
CodeCruiserCommented:
Again more details required.
0
 
TrialUserAuthor Commented:
I am displaying the product results in asp:listview. I would be sorting on stuff like :

Price from Low to High
Price from High to Low
ProductName
Best Selling

and so on
0
 
CodeCruiserCommented:
Try this code


DDLSort_SelectedIndexChanged:

If DDLSort.Text = "Price from Low to High" Then
   dSet.Tables(0).DefaultView.Sort = "Price"
ElseIf DDSort.Text = "Price from High to Low" Then
   dSet.Tables(0).DefaultView.Sort = "Price Desc"
...
End If
ListView1.DataSource = dSet.DefaultView
ListView1.DataBind()
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now