GridCheckbox column won't bind

8 posts, 0 answers
  1. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 22 Feb 2012 Link to this post

    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?

  2. Princy
    Princy avatar
    17237 posts
    Member since:
    Mar 2007

    Posted 23 Feb 2012 Link to this post

    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.

  3. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 23 Feb 2012 Link to this post

    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.

  4. Casey
    Casey avatar
    299 posts
    Member since:
    Jul 2009

    Posted 23 Feb 2012 Link to this post

    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

  5. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 23 Feb 2012 Link to this post

    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>

  6. Casey
    Casey avatar
    299 posts
    Member since:
    Jul 2009

    Posted 23 Feb 2012 Link to this post

    Where are you selecting isOverride from? I don't see it in your SqlDataSource.

  7. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 23 Feb 2012 Link to this post

    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!

  8. Casey
    Casey avatar
    299 posts
    Member since:
    Jul 2009

    Posted 23 Feb 2012 Link to this post

    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

Back to Top