First I will tell you some background, I needed to create a grid with dynamic columns, the column count would be based on user selection, in my DataTable, I added numbers to columns names to keep their name distinct, then I bind it with my girdview.
Now I need to rename columns headerText and remove the counter numbers from column headers, my gird has one more unbound column which is of type Image, when I try to loop my grid.columns using:
foreach (DataGridViewTextBoxColumn dgc in grdDistProcessing.Columns)
it gives me error
InvalidCastException:
Unable to cast object of type ‘System.Windows.Forms.DataGridViewImageColumn’ to type ‘System.Windows.Forms.DataGridViewTextBoxColumn’.
I also used DataColumn but it gave me same error, another thread says we should use DataControlField but VS did not recognizing it, is it an ASP thing ? or I am missing a reference ?
Please Help.
Rgds,
if you have the var keyword available to you (c#3 and above i think).