5 Answers, 1 is accepted
0
Hi,
When you set the AutoGenerateColumns property of RadGrid to true, the RadGrid control generates a separate column for each data field in the control's assigned datasource. Based on the DataType of the field, the grid control will generate the respective column types :
GridCheckBoxColumn displays a check box to represent a Boolean value. You should bind this column type to a Boolean field by setting its DataField property. If this column type is bound to a data value that is not Boolean, the grid throws an exception.
Therefore, after you have auto generated columns, I would suggest you change your datasource to output a boolean value rather than an integer. The RadGrid will automatically pick this up and enable checkbox for edit.
Regards,
Pavlina
Telerik
When you set the AutoGenerateColumns property of RadGrid to true, the RadGrid control generates a separate column for each data field in the control's assigned datasource. Based on the DataType of the field, the grid control will generate the respective column types :
- GridBoundColumn for string fields
- GridCheckBoxColumn for boolean fields
- GridDateTimeColumn for datetime fields
- GridNumericColumn for numeric fields
GridCheckBoxColumn displays a check box to represent a Boolean value. You should bind this column type to a Boolean field by setting its DataField property. If this column type is bound to a data value that is not Boolean, the grid throws an exception.
Therefore, after you have auto generated columns, I would suggest you change your datasource to output a boolean value rather than an integer. The RadGrid will automatically pick this up and enable checkbox for edit.
Regards,
Pavlina
Telerik
DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.
0
DEV
Top achievements
Rank 1
answered on 14 Mar 2014, 09:25 PM
Thanks for the reply.
I already converted my datasource to Boolean but now I have another issue. I want to select/deselect checkbox from those Autogeneratedcolumns but those are disabled by default. Please tell me the right way to enable Autogenerated checkbox.
I already converted my datasource to Boolean but now I have another issue. I want to select/deselect checkbox from those Autogeneratedcolumns but those are disabled by default. Please tell me the right way to enable Autogenerated checkbox.
0
Shinu
Top achievements
Rank 2
answered on 17 Mar 2014, 06:36 AM
Hi Dev,
It is the default behavior of the GridCheckBoxColumn. When the grid is in browser mode, or if the column is read-only, the check box is disabled. When the column is editable, the check box is enabled. Check out the following document to understand better about the various columns supported by RadGrid.
Column types.
Thanks,
Shinu
It is the default behavior of the GridCheckBoxColumn. When the grid is in browser mode, or if the column is read-only, the check box is disabled. When the column is editable, the check box is enabled. Check out the following document to understand better about the various columns supported by RadGrid.
Column types.
Thanks,
Shinu
0
DEV
Top achievements
Rank 1
answered on 17 Mar 2014, 04:03 PM
Thanks for the reply.
Should I use ItemDataBound or ItemCreated event to enable editmode of AutoGenerated GridCheckBox ?
Can you help me with sample code?
Should I use ItemDataBound or ItemCreated event to enable editmode of AutoGenerated GridCheckBox ?
Can you help me with sample code?
0
Shinu
Top achievements
Rank 2
answered on 18 Mar 2014, 04:09 AM
Hi Dev,
I guess you want to have the Grid in edit mode. You can set the AutoGenerateEditColumn property of the RadGrid to true.
ASPX:
Please try and let me know if any concern.
Thanks,
Shinu
I guess you want to have the Grid in edit mode. You can set the AutoGenerateEditColumn property of the RadGrid to true.
ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateEditColumn="true">Please try and let me know if any concern.
Thanks,
Shinu