Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid Sorting with comma Delimeter

Status
Not open for further replies.

arunglobal

Programmer
Sep 8, 2003
40
IN
Hi Guys,

Iam Filling a datagrid with dataTable. Data Table has Numeric Values. I Just want to format my Numeric Values with comma.

i.e dr(rowindex) = Format(prdtsum, "###,###,###,###,###,###,##0")

Its working Fine. Numeric values are formatted bu comma delimeter.

But Data Grid Sorting is not happening.i.e After formatting
the numeric values become string.

So when the coloum Header is clicked the datagrid values are not getting sorted based on numeric values.

Thanks in Advance.


 
You need to define a datagrid format. To do this though you will need to use early data binding.

stravis
 
Its better to sort data in your SQL query rather than using DataGrid to sort the data. Assuming your are using SQL Server database, below is a sample SQL query which displays records in required format i.e. with "$" and "," sings and sorted on numeric values.

SELECT ITR_ID,'$'+convert(varchar,TaxIncFrom,1) AS 'From','$'+convert(varchar,TaxIncTo,1) AS 'To','$'+convert(varchar,TaxBase,1) AS 'TaxBase',convert(varchar,Rate,1)+'%' AS 'Rate',TaxIncFrom,TaxIncTo FROM Income_Tax_Rates ORDER BY TaxIncFrom,TaxIncTo

hope this helps

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top