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

How to create CRUD with rad grid?

3 Answers 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Swapnil
Top achievements
Rank 1
Swapnil asked on 25 Sep 2012, 05:53 AM
how to do crud with rad grid using in  built grid properties
AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticInserts="true"

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Sep 2012, 06:05 AM
Hi,

You can perform automatic CRUD operations by setting AllowAutomaticDeletes as True , AllowAutomaticInserts as True and  AllowAutomaticUpdates as True.
aspx:
<telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowAutomaticDeletes="True"
        AllowAutomaticInserts="True" PageSize="10" AllowAutomaticUpdates="True" . . . .>
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString35 %>"
        DeleteCommand="DELETE FROM [Products] WHERE [ProductID] = @ProductID"
        InsertCommand="INSERT INTO [Products] ([ProductName], [CategoryID]) VALUES (@ProductName, @CategoryID)"
        SelectCommand="SELECT [ProductID], [ProductName] FROM [Products]"
        UpdateCommand="UPDATE [Products] SET [ProductName] = @ProductName, [CategoryID] = @CategoryID WHERE [ProductID] = @ProductID">
        <DeleteParameters>
            <asp:Parameter Name="ProductID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="ProductName" Type="String" />
            <asp:Parameter Name="CategoryID" Type="Int32" />
      </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="ProductName" Type="String" />
            <asp:Parameter Name="CategoryID" Type="Int32" />
            <asp:Parameter Name="ProductID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
Also check the following demo.
Grid / Automatic Operations

Thanks,
Shinu.
0
Swapnil
Top achievements
Rank 1
answered on 25 Sep 2012, 06:29 AM
1)The grid is looking same as previous grid , there is no new text boxes or button or labels for insert ,update and delete.
2)i am using Entity Framework so how to write that stored procedure and where to write.
Plz help,
Thanks
0
Shinu
Top achievements
Rank 2
answered on 26 Sep 2012, 04:43 AM
Hi,

You can configure the EntityDataSource as shown below. Here is the demo which explains the same.
aspx:
<asp:EntityDataSource ID="EntityDataSourceCustomers" runat="server" EntitySetName="Customers" OrderBy="it.[ContactName]"
EntityTypeFilter="Customers" EnableUpdate="True" EnableDelete="True" EnableInsert="True">
</asp:EntityDataSource>

Thanks,
Shinu.
Tags
Grid
Asked by
Swapnil
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Swapnil
Top achievements
Rank 1
Share this question
or