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

cannot insert null

1 Answer 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andreas Lohr
Top achievements
Rank 1
Andreas Lohr asked on 30 Nov 2012, 10:11 AM
hi,
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,
    PRIMARY KEY CLUSTERED ([ProjectId] ASC)
);
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)">
        <DeleteParameters>
            <asp:Parameter Name="ProjectId" DbType="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Project" DbType="String" />
            <asp:SessionParameter Name="OrganizationId" SessionField="OrganizationId" DbType="Guid" />
        </InsertParameters>
        <SelectParameters>
            <asp:SessionParameter Name="OrganizationId" SessionField="OrganizationId" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="Projects" DbType="String" />
            <asp:SessionParameter Name="OrganizationId" SessionField="OrganizationId" DbType="Guid" />
        </UpdateParameters>
    </asp:SqlDataSource>
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>
</RowIndicatorColumn>
 
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
 
    <Columns>
        <telerik:GridBoundColumn DataField="ProjectId" DataType="System.Int32" FilterControlAltText="Filter ProjectId column" HeaderText="ProjectId" ReadOnly="True" SortExpression="ProjectId" UniqueName="ProjectId">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Project" FilterControlAltText="Filter Project column" HeaderText="Project" SortExpression="Project" UniqueName="Project">
        </telerik:GridBoundColumn>
    </Columns>
 
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
</MasterTableView>
 
<FilterMenu EnableImageSprites="False"></FilterMenu>
    </telerik:RadGrid>
It would be really nice, if some pros can tell me, what is wrong.
Thanks in advance!
Andreas

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 05 Dec 2012, 08:12 AM
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.

Greetings,
Kostadin
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.
Tags
Grid
Asked by
Andreas Lohr
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or