Padleft Method

liunx

Guest
Padleft Method

I am having problem in sorting user id in datagrid..

user id must be 6 digits, but some users have these id 000020, 000019, 000018..
and the database shows them without the leading zeros: 20, 19, 18
so how can i show the leading zeros in binding the datagrid? and how can i use padleft() method in datagrid?Are the fields numeric in the database or character based? If they are numeric then you'll want to convert them to characters in the select and use the format options to tell it to pad them. Unfortunately I use Oracle now and I don't remember the exact syntax for SQL Server anymore... but it should be something like this:

Select To_Char(myNumber, '000000') from myTable where ...Thanks.. i'll try it :)
 
Back
Top