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

radgrid commanditem performinsert not firing

1 Answer 164 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Soni
Top achievements
Rank 1
Soni asked on 25 Nov 2014, 04:26 AM
i have created radgrid as picture in attacment
my goals is to create empty radgrid then add the row with RadGrid Automatic Operation(performinsert())
but i can't fire the method anyway, when i click insert like attachment's picture nothing happen

i bind the grid with OnNeedDataSource with DataTable(without sqldatasource like others online tutorials)


here's the code
public void rg1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
       {
            
           DataTable temp = new DataTable();
           temp.Columns.Add("Display", typeof(string));
           temp.Columns.Add("Value", typeof(string));
           rg1.DataSource = temp;
       }
public void rg1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
       {
           if (e.CommandName == RadGrid.PerformInsertCommandName)
           {
               GridEditableItem item = e.Item as GridEditableItem;
               rg1.MasterTableView.PerformInsert(item);
               rg1.Rebind();
               //RadTextBox rbrbrbrb = new RadTextBox();
               //rbrbrbrb.Text = "tes";
               //radAP4.Controls.Add(rbrbrbrb);
 
           }
       }
<telerik:RadGrid runat="server" ID="rg1" AutoGenerateColumns="true" AllowPaging="true" GridLines="None" Width="500px" Height="250px" AllowAutomaticInserts="true" AllowAutomaticDeletes="true" AllowAutomaticUpdates="true" OnNeedDataSource="rg1_NeedDataSource" AutoGenerateEditColumn="true" AutoGenerateDeleteColumn="true" OnItemCommand="rg1_ItemCommand"> <%--OnItemInserted="rg1_ItemInserted">--%>
            <MasterTableView runat="server" CommandItemDisplay="Top" AutoGenerateColumns="true" EditMode="InPlace" AllowAutomaticInserts="true" AllowAutomaticDeletes="true" AllowAutomaticUpdates="true">
                <CommandItemTemplate>
                    <telerik:RadToolBar ID="rtb1" runat="server" AutoPostBack="true">
                        <Items>
                            <telerik:RadToolBarButton Text="Edit selected" CommandName="EditSelected" Visible='<%# rg1.EditIndexes.Count == 0 %>'></telerik:RadToolBarButton>
                             <telerik:RadToolBarButton Text="Update" CommandName="UpdateEdited" Visible='<%# rg1.EditIndexes.Count > 0 %>'></telerik:RadToolBarButton>
                            <telerik:RadToolBarButton Text="Cancel editing" CommandName="CancelAll" Visible='<%# rg1.EditIndexes.Count > 0 || rg1.MasterTableView.IsItemInserted %>'></telerik:RadToolBarButton>
                            <telerik:RadToolBarButton Text="Add new" CommandName="InitInsert" Visible='<%# !rg1.MasterTableView.IsItemInserted %>'></telerik:RadToolBarButton>
                           
                             <telerik:RadToolBarButton Text="Add this Customer" CommandName="PerformInsert" Visible='<%# rg1.MasterTableView.IsItemInserted %>'></telerik:RadToolBarButton>
                            <telerik:RadToolBarButton Text="Delete selected customers" CommandName="DeleteSelected"></telerik:RadToolBarButton>
                        <telerik:RadToolBarButton Text="Refresh customer list" CommandName="RebindGrid" ></telerik:RadToolBarButton>
                        </Items>
                    </telerik:RadToolBar>
                </CommandItemTemplate>
            </MasterTableView>
            <ClientSettings>
                <Selecting AllowRowSelect="true" EnableDragToSelectRows="true" />
            </ClientSettings>
        </telerik:RadGrid>

please help

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 27 Nov 2014, 12:04 PM
Hi Soni,

Note that automatic Insert/Delete/Update is only possible for Declarative DataSource. In case of NeedDataSource you can explicitly write the queries for Insert/update/Delete operations. You can take a look into the following documentation

Insert/Update/Delete at Database Level with Queries

Regards,
Maria Ilieva
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Soni
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or