Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
can anyone plz tell me the purpose of the following code,
C#
objDataSet.Tables[0].DefaultView.Sort = ViewState["sortColumn"]+ " " + ViewState["sortDirection"];

while running my application am getting error "coloumn not found" and the error is with this code so plz explain me the meaning of this line.
Posted
Updated 20-Jun-12 1:27am
v2

objDataSet.Tables[0].DefaultView.Sort = ViewState["sortColumn"]+ " " + ViewState["sortDirection"];
Above line is setting the default sort column and direction for the table.

getting error "coloumn not found"
This means that the columnname returned/set by above line does not exists in table: objDataSet.Tables[0]

Possible reason:
1. ViewState["sortColumn"] returned null
2. ViewState["sortColumn"] returned a column name that does not exists in objDataSet.Tables[0]

Check and handle/correct it.
 
Share this answer
 
Comments
Vani Kulkarni 20-Jun-12 7:46am    
Experience speaks ;-) My 5!
Sandeep Mewara 20-Jun-12 9:32am    
Thanks. :)
Shahin Khorshidnia 20-Jun-12 8:11am    
Good explaination. +5
Sandeep Mewara 20-Jun-12 9:32am    
Thanks Shahin.
Am Gayathri 20-Jun-12 8:20am    
Thanks a lot....:)
This code is for sorting data in asp.net
so sortcolumn and sortdirection is used
 
Share this answer
 
v2
can u post the entire code.
i mean.... u getting at viewstate coloumn not found but need to assign the value to the viewstate... so need to check where it will assign the value.

Warm regards.

shivanand Nagarabetta.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900