Sorting GridView according an IP column
-
Hi, I have a page that displays data in GridView. The data is obtained from an SQL Server database. One column is an IP addresses, which are stored as VarChar(15) in the database. The page executes a select statemnet and bind the GridView with the DataTable obtained by executing this SQL statement. The problem is that I want to allow the user to sort the Grid according to the IPs column. Taking into consideration, that IP 10.5.0.0 should come before 10.30.0.0 in ascending sorting. So, I can't rely on the built in sorting of the GridView. Kind regards, Ahmed
-
Hi, I have a page that displays data in GridView. The data is obtained from an SQL Server database. One column is an IP addresses, which are stored as VarChar(15) in the database. The page executes a select statemnet and bind the GridView with the DataTable obtained by executing this SQL statement. The problem is that I want to allow the user to sort the Grid according to the IPs column. Taking into consideration, that IP 10.5.0.0 should come before 10.30.0.0 in ascending sorting. So, I can't rely on the built in sorting of the GridView. Kind regards, Ahmed
-
You can always create a computed column that brings the numerical value of the ipaddress then override the SortCommand and specify the computed column as the sort expression
I was looking forward for something like the Sort function of the System.Array class, to which I can pass a class implementing IComparer. It seems there is no other way than that indianet had posted. Thanks indianet for your help.