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

GridCheckBoxColumn and LinqtoSQL

2 Answers 101 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 2
Elliott asked on 30 Jun 2010, 06:55 PM
the GridCheckBoxColumn and LinqtoSQL don't seem to play well together
a LinqtoSQL data source seems to completely bypass a postback (a good thing, usually) so I can't just go into the ItemDataBinding event and manually set the column
the column appears but doesn't show any data
if I add a DataType an exception is thrown - something about being unable to convert a string to boolean
any assistance is appreciated
I'm working in VS2010, SQL Server 2005, latest and greatest Telerik RAD Ajax controls

the relevant aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="AdminPage.aspx.vb" Inherits="AdminPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
<head runat="server">
    <title>Admin Page</title>
<form id="frmAdmin" runat="server">
    <telerik:RadScriptManager ID="rsManager" runat="server" />
        <telerik:RadGrid ID="gvVendor" DataSourceID="ldsVendor" runat="server">
        <MasterTableView DataKeyNames="VendorID" AutoGenerateColumns="false" AllowSorting="true" AllowPaging="true" CommandItemDisplay="Top" >
            <telerik:GridBoundColumn UniqueName="VendorID" DataField="VendorID" HeaderText="VendorID" ReadOnly="true" />
            <telerik:GridBoundColumn UniqueName="VendorName" DataField="VendorName" HeaderText="Vendor Name" />
            <telerik:GridBoundColumn UniqueName="LNSPrefix" DataField="LNSPrefix" HeaderText="LNSPrefix" />
            <telerik:GridBoundColumn UniqueName="KMSPrefix" DataField="KMSPrefix" HeaderText="KMSPrefix" />
            <telerik:GridCheckBoxColumn UniqueName="RepGroupFlag" DataFieldName="RepGroupFlag" HeaderText="Rep Group?" />
            <telerik:GridEditCommandColumn UniqueName="btnEdit" />
            <telerik:GridClientDeleteColumn UniqueName="btnDelete" />
    <asp:LinqDataSource ID="ldsVendor" TableName="Vendors" ContextTypeName="LtSVandorDataContext" EntityTypeName=""
        Select="new (VendorID,VendorName,LNSPrefix,KMSPrefix,RepGroupFlag)" OrderBy="VendorName"
        EnableDelete="True" EnableInsert="True" EnableUpdate="True" runat="server"></asp:LinqDataSource>

code behind
Imports System.Data
Imports Telerik.Web.UI

Partial Class AdminPage
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Page.IsPostBack Then
            Exit Sub
        End If
    End Sub

why won't the grid set the checkbox properly?
I get a String was not recognized as a valid Boolean. exception thrown - but the column is tinyint
adding a DataType of System.Int16 does nothing


2 Answers, 1 is accepted

Sort by
Telerik team
answered on 06 Jul 2010, 08:23 AM
Hello Marianne,

Here is a small quote from our documentation:

"GridCheckBoxColumn displays a check box to represent a boolean value. 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."

Based on that I would suggest that you try binding your GridCheckBoxColumn to a valid boolean field and verify whether the issue still exists.

I hope this helps,
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Top achievements
Rank 2
answered on 06 Jul 2010, 01:18 PM
I left the SQL alone (returning TINYINT) and on the ItemDataBound event handler isolated both the checkbox and the underlying datagridrow
on update, pass the boolean from the checkbox to the update routine and if yes then 1 else 0

or I could have put a case statement in the stored procedure which builds the grid to return True if 1 or False if 0
Asked by
Top achievements
Rank 2
Answers by
Telerik team
Top achievements
Rank 2
Share this question