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

RadGrid Control Custom Implementation of Select/Insert/Update/Delete Commands without using the SQLDataSource

2 Answers 209 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Uma
Top achievements
Rank 1
Uma asked on 28 Jan 2011, 08:11 PM
Hi, we are working on implementing Select/Insert/Update/Delete functionality using RADGrid, it is working if we use <asp:SqlDataSource>

But when we implemented the events to call our own DAOs and do the Select/Insert/Update/Delete functionality  using the custom code

the events are not getting what can be going wrong

Thanks

The code that works:

 <
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadGridEquityCharacterstics">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGridEquityCharacterstics" />
                    </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
           
            <telerik:RadGrid ID="RadGridEquityCharacterstics" runat="server" AllowSorting="true" DataSourceID="SqlDataSource1"
                AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="true"
                ShowStatusBar="true" Skin="Sunset" AllowMultiRowEdit="True">
                <MasterTableView AutoGenerateColumns="False" DataKeyNames="EquityCharId" DataSourceID="SqlDataSource1"
                CommandItemDisplay="TopAndBottom" EditMode="EditForms">
                    <Columns>
                        <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="imagebutton" />
                        <telerik:GridBoundColumn DataField="EquityCharId" DataType="System.Int32" HeaderText="EquityCharId"
                            ReadOnly="True" SortExpression="EquityCharId" UniqueName="EquityCharId" Visible="False"/>   
                        <telerik:GridBoundColumn DataField="CharType" HeaderText="CharType" SortExpression="CharType"
                            UniqueName="CharType" />
                        <telerik:GridBoundColumn DataField="RepAccount" HeaderText="RepAccount" SortExpression="RepAccount"
                            UniqueName="RepAccount" />
                        <telerik:GridBoundColumn DataField="AccountABC" HeaderText="ABC" SortExpression="AccountABC"
                            UniqueName="Account703" />
                        <telerik:GridBoundColumn DataField="AccountBCD" HeaderText="BCD" SortExpression="AccountBCD"
                            UniqueName="Account103" />
                        <telerik:GridBoundColumn DataField="SP500" HeaderText="S&P 500" SortExpression="SP500"
                            UniqueName="SP500" />
                        <telerik:GridBoundColumn DataField="R1000" HeaderText="R 1000 Value" SortExpression="R1000"
                            UniqueName="R1000" />
                        <telerik:GridBoundColumn DataField="AsOfDate" DataType="System.DateTime" HeaderText="AsOfDate"
                            SortExpression="AsOfDate" UniqueName="AsOfDate" DataFormatString="{0:MM/dd/yyyy}"/>
                        <telerik:GridButtonColumn UniqueName="ButtonColumn" Text="Delete" CommandName="Delete"
                            ButtonType="imagebutton" />
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
            <br />
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DCMaster %>"
                SelectCommandType="StoredProcedure" SelectCommand="SelectEDCEquityCharacterstics" DeleteCommandType="StoredProcedure"
                DeleteCommand="DeleteEDCEquityCharacterstics" UpdateCommandType="StoredProcedure" UpdateCommand="UpdateEDCEquityCharacterstics"
                InsertCommandType="StoredProcedure" InsertCommand="InsertEDCEquityCharacterstics">
            <UpdateParameters>
                <asp:Parameter Name="CharType" Type="String" />
                <asp:Parameter Name="RepAccount" Type="String" />
                <asp:Parameter Name="AccountABC" Type="String" />
                <asp:Parameter Name="AccountBCD" Type="String" />
                <asp:Parameter Name="SP500" Type="String" />
                <asp:Parameter Name="R1000" Type="String" />
                <asp:Parameter Name="AsOfDate" Type="DateTime" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="CharType" Type="String" />
                <asp:Parameter Name="RepAccount" Type="String" />
                <asp:Parameter Name="AccountABC" Type="String" />
                <asp:Parameter Name="AccountBCD" Type="String" />
                <asp:Parameter Name="SP500" Type="String" />
                <asp:Parameter Name="R1000" Type="String" />
                <asp:Parameter Name="AsOfDate" Type="DateTime" />
            </InsertParameters>
            </asp:SqlDataSource>
        </div>
        </form>


The code that does not work
<
private void RadGridEquityCharacterstics_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { 
GridEditableItem editedItem = e.Item as GridEditableItem
Label1.Text =
"Insert Command";  
//This is eVent is not fired
}

>

 

 

 

 

 

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Uma
Top achievements
Rank 1
answered on 28 Jan 2011, 09:23 PM
one other i tried which is also not working

<

<

 

telerik:RadGrid ID="RadGridEquityCharacterstics" runat="server" AllowSorting="true"

 

 

AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="true"

 

 

ShowStatusBar="true" Skin="Sunset" AllowMultiRowEdit="True"

 

 

OnNeedDataSource="RadGridEquityCharacterstics_NeedDataSource"

 

 

OnUpdateCommand="RadGridEquityCharacterstics_UpdateCommand"

 

 

OnItemCreated="RadGridEquityCharacterstics_ItemCreated"

 

 

OnDeleteCommand="RadGridEquityCharacterstics_DeleteCommand"

 

 

OnInsertCommand="RadGridEquityCharacterstics_InsertCommand">

 

>

it is giving the error

<

 

Server Error in '/' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0123: No overload for 'RadGridEquityCharacterstics_UpdateCommand' matches delegate 'Telerik.Web.UI.GridCommandEventHandler'

Source Error:

Line 127:            </telerik:RadAjaxManager>
Line 128:            
Line 129: <telerik:RadGrid ID="RadGridEquityCharacterstics" runat="server" AllowSorting="true" Line 130:                AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="true"
Line 131:                ShowStatusBar="true" Skin="Sunset" AllowMultiRowEdit="True"

Source File: d:\Uma\Projects\Sharepoint\DC.Web\DataCapture\EquityCharacterstics.aspx    Line: 129


>
0
Princy
Top achievements
Rank 2
answered on 31 Jan 2011, 09:44 AM
Hello Uma,

Please take a look at the following code library which shows how to perform manual insert/update/delete operation.
Manual Insert/Update/Delete operations using Auto-generated editform with sql statements from the code-behind:

Hope this helps,
Princy.
Tags
Grid
Asked by
Uma
Top achievements
Rank 1
Answers by
Uma
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or