Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 18th, 2006, 04:19 AM
Registered User
 
Join Date: Dec 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think the best solution is to add two parameters in the stored procedure,one for the column(field) name and the other one specify whether sorting is ASC/DESC.

If you don't want to do this, then you can add these lines in your code behind.


DataTable dTablePropertyList = new DataTable(); // declaring new datatable

//setting cloumn name and datatype
    foreach(DataColumn dColumnProperty in dSetPropertyList.Tables[0].Columns)
    {
        if(dColumnProperty.ColumnName.ToString().Trim().To Upper() == "VIEWEDCOUNT")
        {
            dTablePropertyList.Columns.Add(dColumnProperty.Col umnName,System.Type.GetType("System.Int32"));
        }
        else
        {
            dTablePropertyList.Columns.Add(dColumnProperty.Col umnName,dColumnProperty.DataType);
        }
    }
//adding rows to datatable
    foreach(DataRow dRowPropertyin dTablePropertyList.Tables[0].Rows )
    {
        DataRow dRow = dTablePropertyList.NewRow();
        dRow[0] = dRowProperty[0];
        dRow[1] = dRowProperty[1];
        dRow[2] = dRowProperty[2];
        dRow[3] = dRowProperty[3];
        dRow[4] = dRowProperty[4];
        dRow[5] = dRowProperty[5];
        dRow[6] = dRowProperty[6];

        dTablePropertyList.Rows.Add(dRow);
    }
DataView dViewPropertyList = new DataView(dTablePropertyList);

//


dViewPropertyList.Sort=Session["sortExpProperty"] + " " + Session["sortExpPropertyOrder"];

dGridProperty.DataSource = dViewPropertyList ;
dGridProperty.DataBind();



         hope this will help:)



 
Old August 17th, 2006, 03:11 PM
Registered User
 
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am having the same problem. I have checked the data type of the field in the data view and it is an integer. However, it will not apply a numeric sort. I did find one stranage thing. If I left of the asc or desc and only specified the field name in the sort command like (.sort = "field1") instead of (.sort = "field1 asc"), it performed a numeric sort. But as soon as I add the asc or desc part, it does a string sort. I just wondering if it does the same for you.

Ken Morman
 
Old November 15th, 2006, 12:40 PM
Registered User
 
Join Date: Nov 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your datatable's fields are text fields by default. In a text field 15 is smaller than 20. When you define your datatable, make sure you define the datatype as being integer like the following, then it will sort correctly.

SurveyQAArray.Columns.Add("intQSortOrder", GetType(Integer))






Similar Threads
Thread Thread Starter Forum Replies Last Post
From numeric to alfa numeric ebekir XSLT 1 August 10th, 2007 06:13 AM
Sorting Datefield in a DataView Wanda ASP.NET 2.0 Basics 0 January 11th, 2007 04:13 PM
Sorting With dataView anubhav.kumar ADO.NET 1 March 17th, 2005 05:06 AM
DataView Not Sorting pbyrum C# 3 December 27th, 2004 06:30 PM
Datagrid sorting by non alphabetical sorting? LLAndy VS.NET 2002/2003 1 July 15th, 2004 01:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.