Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Datagrid / Dataview won't sort

Reply
Thread Tools

Datagrid / Dataview won't sort

 
 
troyblakely@gmail.com
Guest
Posts: n/a
 
      11-05-2005
I am having trouble sorting a datagrid. I have read numerous posts on
this and other lists, and tried most of the suggestions, but none of
them have worked for me yet. I populate a dataset from two queries,
then I want to sort the data and bind it to a datagrid. Regardless of
what I have tried, the datagrid is populated with the unsorted data.
Any assistance you have would be appreciated.

I have attempted the sort using the dataview.sort method. See Below:

DataView view = this.dsInventory1.Tables["vInvLocDetail"].DefaultView;
view.Sort = "invTypeDesc ASC";
this.DataGrid1.DataSource = view;
this.DataGrid1.DataBind();


I have also attempted creating the dataview, specifying the sort for
the dataview, then parsing the results of the dataview into another
datatable and binding the datagrid to that datatable. See below:

DataView dv = new DataView(this.dsInventory1.vInvLocDetail, "",
"invTypeDesc", DataViewRowState.CurrentRows);
dv.Sort = "invTypeDesc";
DataTable dt = new DataTable();
foreach (DataRow row in dv.Table.Rows)
{
dt.ImportRow(row);
}
this.DataGrid1.DataSource = dt;
this.DataGrid1.DataBind();

Thank you for helping!

 
Reply With Quote
 
 
 
 
Patrick.O.Ige
Guest
Posts: n/a
 
      11-05-2005
Troy try looking at this at:-
http://www.dotnetjohn.com/articles.aspx?articleid=108
Hope that helps
Patrick

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> I am having trouble sorting a datagrid. I have read numerous posts on
> this and other lists, and tried most of the suggestions, but none of
> them have worked for me yet. I populate a dataset from two queries,
> then I want to sort the data and bind it to a datagrid. Regardless of
> what I have tried, the datagrid is populated with the unsorted data.
> Any assistance you have would be appreciated.
>
> I have attempted the sort using the dataview.sort method. See Below:
>
> DataView view = this.dsInventory1.Tables["vInvLocDetail"].DefaultView;
> view.Sort = "invTypeDesc ASC";
> this.DataGrid1.DataSource = view;
> this.DataGrid1.DataBind();
>
>
> I have also attempted creating the dataview, specifying the sort for
> the dataview, then parsing the results of the dataview into another
> datatable and binding the datagrid to that datatable. See below:
>
> DataView dv = new DataView(this.dsInventory1.vInvLocDetail, "",
> "invTypeDesc", DataViewRowState.CurrentRows);
> dv.Sort = "invTypeDesc";
> DataTable dt = new DataTable();
> foreach (DataRow row in dv.Table.Rows)
> {
> dt.ImportRow(row);
> }
> this.DataGrid1.DataSource = dt;
> this.DataGrid1.DataBind();
>
> Thank you for helping!
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorted DataView, but unsorted datalist when bound to the dataview CodeMonkey ASP .Net 1 02-04-2011 10:55 AM
Sort an XML document using DataView =?Utf-8?B?RWQgQ2hpdQ==?= ASP .Net 1 12-14-2004 07:51 PM
DataView.Sort causing duplicate entries in a DataGrid control Grant Harmeyer ASP .Net Datagrid Control 0 06-15-2004 07:05 PM
Query on DataView.Sort Property Denzil ASP .Net 1 10-22-2003 11:01 PM
Ado sort error-Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. Navin ASP General 1 09-09-2003 07:16 AM



Advertisments