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

GridCheckbox column won't bind

7 Answers 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Web Services
Top achievements
Rank 2
Web Services asked on 22 Feb 2012, 11:40 PM
I'm binding a rad grid with a sql data source and it's working fine except for my gridcheckbox column. What type does the db column have to be for it to bind automatically. I've tried bit, and nvarchar with true/false?

7 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Feb 2012, 06:07 AM
Hello,

When GridCheckboxColumn is bound to a data value that is not boolean, the grid throws an exception. Check the following help documentation which explains more about this.
Column Types.

Thanks,
Princy.
0
Web Services
Top achievements
Rank 2
answered on 23 Feb 2012, 03:41 PM
Then why does my grid load fine, it gives me no error. Also, you can't store a boolean in sql server. The closest field is a bit, does that mean I'll have to manually go through the grid and check all of the checkboxes.
0
Casey
Top achievements
Rank 1
answered on 23 Feb 2012, 04:24 PM
Could you please post your RadGrid's definition?  Also, what are the values for that column in sql server (0 & 1, 'T' & 'F', etc...)? 

Thanks!
Casey
0
Web Services
Top achievements
Rank 2
answered on 23 Feb 2012, 04:30 PM
Sure, I took out all the other columns to make it easier to read but I do have other columns in this, but they are loading fine. My question is, what does the database field need to be? I can make it anything, I just can't figure out what the checkbox needs? I know you say it needs a boolean, but I tried changing the column isoverride to nvarchar and setting some values to 'true' and that didn't work. I also tried a bit where the values were 0 and 1 and that didn't work either. Right now, my column is bit returning 0 or 1

<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
<script type="text/javascript">
 
    function RowDblClick(sender, eventArgs) {
        idx = eventArgs.get_itemIndexHierarchical();
        sender.get_masterTableView().editItem(idx);
    }
    function RowClick(sender, eventArgs) {
        idx = eventArgs.get_itemIndexHierarchical();
        sender.get_masterTableView().editItem(idx);
    }
 
    </script>
    <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" AllowPaging="False" BorderStyle="Solid"
            BorderColor="#0f0F6F"  CellPadding="5" DataSourceID="SqlDataSource1"
            AllowSorting="False" AutoGenerateColumns="false" Width="950px" OnUpdateCommand="radgridUpdate">
            <ClientSettings>
                <ClientEvents OnRowDblClick="RowDblClick" />
                <ClientEvents OnRowClick="RowClick" />
            </ClientSettings>
            <MasterTableView DataKeyNames="overrideId" AutoGenerateColumns="false" EditMode="PopUp">
                <ItemStyle CssClass="myRow" Height="60px" />
                <AlternatingItemStyle CssClass="alternateRow" Height="60px" />
                <RowIndicatorColumn>
                    <HeaderStyle Width="20px" HorizontalAlign="Right"></HeaderStyle>
                </RowIndicatorColumn>
                <ExpandCollapseColumn>
                    <HeaderStyle Width="20px"></HeaderStyle>
                </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridCheckBoxColumn DataField="isOverride" HeaderText="Override" SortExpression="isoverride"
                        UniqueName="isoverride" >
                    </telerik:GridCheckBoxColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
 
    
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:connection %>"
        SelectCommand="SELECT [overrideId], [name], [pointId], ISNULL([minValue], 0) AS minValue, ISNULL([maxValue], 0) AS maxValue,
                        ISNULL([defaultValue], 0) as defaultValue, ISNULL([overrideValue], 0) AS overridValue FROM [Override]">
    </asp:SqlDataSource>

0
Casey
Top achievements
Rank 1
answered on 23 Feb 2012, 04:36 PM
Where are you selecting isOverride from? I don't see it in your SqlDataSource.
0
Web Services
Top achievements
Rank 2
answered on 23 Feb 2012, 04:57 PM
God now I feel like an idiot. It just wasn't in my data source. I almost always bind in the code behind using a data table, and the grid will throw an error if one of the columns doesn't exist. I didn't know it wouldn't do that if it wasn't in the data source so I didn't think to check. Sorry for wasting your time. You guys have such good support here and with your tickets, it's really the only reason I'm renewing my license next month. thanks!
0
Casey
Top achievements
Rank 1
answered on 23 Feb 2012, 04:59 PM
Don't feel like an idiot, mistakes happen. I'm usually guilty of simply copy/paste mistakes where I forget to change field names or something simple like that haha.

Glad I could help!
Casey
Tags
Grid
Asked by
Web Services
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Web Services
Top achievements
Rank 2
Casey
Top achievements
Rank 1
Share this question
or