开发者

DataView sorting alphabetically

开发者 https://www.devze.com 2023-01-08 15:57 出处:网络
I am getting two inputs from the user. One is modalno and other is description and one add button if the user clicks the add button i goes and it should go and insert in the correct sorting order so f

I am getting two inputs from the user. One is modalno and other is description and one add button if the user clicks the add button i goes and it should go and insert in the correct sorting order so far i have used this code in loadgrid()

DataView dv = ModelDataset.Tables[0].DefaultView;
dv.Sort = "MOD开发者_开发百科EL_NO";
grvModelNo.DataSource = dv;
grvModelNo.DataBind();

It is sorting correctly but my issue is :

modalno    description
1          test
45         test
455        test
50         test

'455' should insert after '50' it is inserting before '50' it is checking first digit only i think.

Note: Here Modal_No is varchar()


It is sorting as text, not as a number. If you want it to sort it as a number, you must present it as a number - cast it.

Why is it a varchar anyway, as it looks a lot like it will only be storing numbers...

0

精彩评论

暂无评论...
验证码 换一张
取 消