custom sorting


P

Paul W

Hi,
I have a datagrid that I build using data returned from a SP. But I
populate the datagrid using a dataview. In this dataview, I populate one of
the columns with a string that is basically an html link. The display text
is always numeric. For instance, the column will display 7, but the value
is something like "<a href='myData.aspx?id=" + reader["MyNumber"].ToString()
+ "'>" + reader["IMyNumber"].ToString() + "</a>";
The problem I am having is that I want to sort the column like it is
numeric. But it is sorting it like a string (which makes sense, but it is
not what I want). So if I have numbers like 1, 2, 3, 11....it will display
as 1, 11, 2, 3 for the sort. I want it to display 1, 2, 3, 11. Is this
even possible? If so, can someone guide me (or give me code) in the right
direction? Thanks
Paul
 
Ad

Advertisements

D

dinil

i guess wht u can do is to add a new column with integer type and copy all
the values there and sort by that column.
 
Ad

Advertisements

P

Paul W

great idea! i did not think about that. thank you.
dinil said:
i guess wht u can do is to add a new column with integer type and copy all
the values there and sort by that column.

Paul W said:
Hi,
I have a datagrid that I build using data returned from a SP. But I
populate the datagrid using a dataview. In this dataview, I populate one of
the columns with a string that is basically an html link. The display text
is always numeric. For instance, the column will display 7, but the value
is something like "<a href='myData.aspx?id=" + reader["MyNumber"].ToString()
+ "'>" + reader["IMyNumber"].ToString() + "</a>";
The problem I am having is that I want to sort the column like it is
numeric. But it is sorting it like a string (which makes sense, but it
is
not what I want). So if I have numbers like 1, 2, 3, 11....it will display
as 1, 11, 2, 3 for the sort. I want it to display 1, 2, 3, 11. Is this
even possible? If so, can someone guide me (or give me code) in the
right
direction? Thanks
Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top