cannot insert null

2 posts, 0 answers
  1. Andreas Lohr
    Andreas Lohr avatar
    29 posts
    Member since:
    Aug 2009

    Posted 30 Nov 2012 Link to this post

    I just try to setup a basic scenario with RadGrid using CRUD.
    So far select and delete works, but update and insert fails. I cannot see, whats going wrong.
    Here is my table definition:
    CREATE TABLE [dbo].[Projects] (
        [ProjectId]      INT              IDENTITY (1, 1) NOT NULL,
        [Project]        NVARCHAR (MAX)   NOT NULL,
        [OrganizationId] UNIQUEIDENTIFIER NOT NULL,
        [Created]        DATETIME         DEFAULT (getdate()) NULL,
        [Updated]        DATETIME         DEFAULT (getdate()) NULL,
    The updated column has a trigger. Hope that is not the problem.
    The SqlDataSource is:
    <asp:SqlDataSource ID="SqlDataSourceProjects" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" DeleteCommand="DELETE FROM Projects WHERE (ProjectId = @ProjectId)" InsertCommand="INSERT INTO Projects(Project, OrganizationId) VALUES (@Project, @OrganizationId)" SelectCommand="SELECT Projects.* FROM Projects WHERE (OrganizationId = @OrganizationId)" UpdateCommand="UPDATE Projects SET Project = @Projects WHERE (OrganizationId = @OrganizationId)">
                <asp:Parameter Name="ProjectId" DbType="Int32" />
                <asp:Parameter Name="Project" DbType="String" />
                <asp:SessionParameter Name="OrganizationId" SessionField="OrganizationId" DbType="Guid" />
                <asp:SessionParameter Name="OrganizationId" SessionField="OrganizationId" />
                <asp:Parameter Name="Projects" DbType="String" />
                <asp:SessionParameter Name="OrganizationId" SessionField="OrganizationId" DbType="Guid" />
    and the radGrid is:
    <telerik:RadGrid ID="RadGridProjects" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" CellSpacing="0" Culture="de-DE" DataSourceID="SqlDataSourceProjects" GridLines="None" Skin="Metro">
    <MasterTableView DataKeyNames="ProjectId" DataSourceID="SqlDataSourceProjects" CommandItemDisplay="TopAndBottom">
    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
    <HeaderStyle Width="20px"></HeaderStyle>
    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
    <HeaderStyle Width="20px"></HeaderStyle>
            <telerik:GridBoundColumn DataField="ProjectId" DataType="System.Int32" FilterControlAltText="Filter ProjectId column" HeaderText="ProjectId" ReadOnly="True" SortExpression="ProjectId" UniqueName="ProjectId">
            <telerik:GridBoundColumn DataField="Project" FilterControlAltText="Filter Project column" HeaderText="Project" SortExpression="Project" UniqueName="Project">
    <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
    <FilterMenu EnableImageSprites="False"></FilterMenu>
    It would be really nice, if some pros can tell me, what is wrong.
    Thanks in advance!

  2. Kostadin
    Kostadin avatar
    1687 posts

    Posted 05 Dec 2012 Link to this post

    Hi Andreas,

    I suggest you check out the following example. Note that you have to insert/edit the OrganizationId because does not accept null and will throw an exception.

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top