Sorting a dataview

G

Guest

Hello,

I am trying to sort the values of a dataset based on the column the user
selects on the web page, how the code below does not sort. I have hard coded
a column for now, but any suggestions would be appreciated.

Dim comInvView As DataView 'Community Inventory View

'Put user code to initialize the page here
Dim objCommunityInventory As DataSet
Dim aSqlParameter(2) As SqlClient.SqlParameter
aSqlParameter(0) = GetSqlParameter("@DivisionID",
Request.QueryString("DivisionID"), SqlDbType.Int)
aSqlParameter(1) = GetSqlParameter("@CommunityID",
Request.QueryString("CommunityID"), SqlDbType.Int)
aSqlParameter(2) = GetSqlParameter("@PhaseID",
IIf(Request.QueryString("PhaseID").ToString = "0", DBNull.Value,
Request.QueryString("PhaseID")), SqlDbType.Int)
objCommunityInventory = New DataSet()
lblDate.Text = Now.ToString

FillDataSet("rptCommunityInventory", aSqlParameter,
CType(objCommunityInventory, Object), "CommunityInventory")

objCommunityInventory.Tables(0).Columns.Remove("Title")
objCommunityInventory.AcceptChanges()


comInvView =
objCommunityInventory.Tables("CommunityInventory").DefaultView()
comInvView.Sort = "Status DESC"
dgCommunityInventory.DataSource = comInvView
dgCommunityInventory.DataBind()


Thanks
Suneet
 
D

Duron

How if

Dim dt As DataTable
dt = objCommunityInventory.Tables("CommunityInventory")
dt.DefaultView.Sort = "Status DESC"
dgCommunityInventory.DataSource = dt.DefaultView
dgCommunityInventory.DataBind()

-Duron
 

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,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top