This is a migrated thread and some comments may be shown as answers.

Chinging autogenerated columns values of checkBox to Yes or No in RadGrid

1 Answer 50 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raj
Top achievements
Rank 1
Raj asked on 25 Nov 2010, 01:27 PM
Hi,

I am using a RadGrid with autogeneratecolumns is Enabled because i have 150 columns in the Grid.

I have many bit fields , for that Grid generating checkboxes.I am exporting the data to excel sheet.

Everything upto here working fine, But when i see the Exported sheet , its not showing anything for the checkBox fields in the excel sheet.

I need to replace or modify the checkBox fields data to YES or NO when the RadGrid loads.

I can do it if i have columns addes using bound fields or template fields.But i am using autogenerated columns , How to fix my problem.

Please help me , If this is not done i have to add 150 template fields manually.

Thank you

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 26 Nov 2010, 04:54 AM
Hello Raj,

You can access the CheckBox in AutoGeneratedColumns by using its FieldName in database. Check out the following code snippet.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridDataItem)
       {
           GridDataItem item = (GridDataItem)e.Item;
           CheckBox chkbox = (CheckBox)item["isapproved"].Controls[0]; // accessing CheckBox using Fieldname in database
           chkbox.Checked = !chkbox.Checked;
       }
   }

And there is one forum post which discusses the same issue of exporting CheckBox data to excel. Please take a look at this post.

Thanks,
Princy.
Tags
Grid
Asked by
Raj
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or