Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
   DataTable dt_GHide = (DataTable)ViewState["GdvVal"];
        if (dt_GHide.Rows.Count > 0)
        {
            for (int i = 0; i < dt_GHide.Rows.Count; i++)
            {

string itemm1 = DataBinder.Eval(grdSale.Rows[i].DataItem, "item1").ToString();  // Getting error
}
}


Any suggestion really appreciate !
Posted
Comments
Thanks7872 17-Jun-13 7:04am    
Check whether ViewState["GdvVal"] is null before this line:

DataTable dt_GHide = (DataTable)ViewState["GdvVal"];
Mahesh Bailwal 17-Jun-13 7:04am    
Can you please explain what are you trying to do? As never used DataBinder.Eval this way.
E.F. Nijboer 17-Jun-13 7:10am    
Set a breakpoint, step through the code and swatch the variables to see what happens.

You probably didn't mean to use grdSale.Rows[i] inside your loop - which would make sense given that the loop is bounded by the length of a totally different object.

Probably, you meant to say:
C#
string itemm1 = DataBinder.Eval(dt_GHide.Rows[i].DataItem, "item1").ToString();

instead of:
C#
string itemm1 = DataBinder.Eval(grdSale.Rows[i].DataItem, "item1").ToString();
 
Share this answer
 
Comments
Prasad_Kulkarni 17-Jun-13 7:22am    
+5! Good find! :)
Please check out viewstate value and if ViewState have value then please check out the value is available or not in "grdSale" dataset by applying the condition:
if(grdSale.rows.count !=0)
{
//Write code here
string itemm1 = DataBinder.Eval(grdSale.Rows[i].DataItem, "item1").ToString();
}
 
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