Click here to Skip to main content
15,906,333 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
In my cs code i have 2 foreach loop for GridViewRow and GridViewColumn
i am using System.Web.UI.WebControls namespace.for GridViewColumn getting error as "Error 3 The type or namespace name 'GridViewColumn' could not be found (are you missing a using directive or an assembly reference?)"

C#
foreach (GridViewRow row in ItemGv.Rows)
   {
   //code --
   }


C#
foreach (GridViewColumn column in ItemGv.Columns)
     {
     //code
     }


could you please help in this

Thanks
Posted
Updated 8-Dec-11 21:33pm
v2
Comments
Code 89 9-Dec-11 4:10am    
no property called GridViewColumn..

Hi,

There is no property called GridViewColumn

If you want to loop through all the columns of a gridview then

C#
for(int i=0;i<urgridid.Columns.Count;i++)
{
//write your logic here
}


Hope this helps....
 
Share this answer
 
Hi,

Try to replace above code line:

C#
foreach (GridViewColumn column in ItemGv.Columns)
{
    //code
}



with:
C#
foreach (var column in this.ItemGv.Columns)
{
    //code -- 
}


Hope this could help...

Regards,
 
Share this answer
 
What exactly are you trying to achieve? Both of the above solutions would help since there is no property as GridViewColumn. You will have to make a ref through the GridView.Column property
 
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