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

RadGrid OnUpdateCommand and OnItemUpdated not fierd

5 Answers 463 Views
Grid
This is a migrated thread and some comments may be shown as answers.
gdr
Top achievements
Rank 1
gdr asked on 04 Nov 2009, 05:24 PM
Hi all,

why does onupdatecommand and onitemupdated not fierd ?? here is the codes : 

aspx :
        <telerik:RadGrid ID="RadGrid1" runat="server" OnItemUpdated="companyGridUpdated" 
            AllowPaging="True" AllowSorting="True" OnUpdateCommand="companyGridUpdate" 
            AutoGenerateColumns="False" GridLines="None" Skin="Vista" AllowAutomaticUpdates="True">
                <MasterTableView ShowFooter="True" DataKeyNames="ID">
                    <Columns>
                        <telerik:GridBoundColumn UniqueName="ID" DataField="ID" Visible="False">
                        </telerik:GridBoundColumn>
                         <telerik:GridBoundColumn UniqueName="CompanyID" DataField="CompanyID" Visible="False">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Name" DataField="Name" UniqueName="Name">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Notes" DataField="Notes" UniqueName="Notes">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Status" DataField="Status" UniqueName="Status">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="IP Address" DataField="IPAddress" UniqueName="IPAddress">
                        </telerik:GridBoundColumn>
                        <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
                        </telerik:GridEditCommandColumn>
                    </Columns>
                    <EditFormSettings EditFormType="Template">
                        <EditColumn UniqueName="EditCommandColumn1">
                        </EditColumn>
                        <FormTemplate>
                            <table id="Table1" style="padding:5px;">
                                <tr valign="top">
                                    <td colspan="2">
                                        <br />
                                        <b>Edit details for 
                                            <asp:Label Id="Label1" Text='<%#Bind("Name") %>' runat="server"></asp:Label>
                                        </b><br />
                                    </td>
                                </tr>
                                <tr valign="top">
                                    <td>
                                        Node Server Name : 
                                    </td>
                                    <td>
                                        <telerik:RadTextBox runat="server" Text='<%#Bind("Name") %>'
                                        ID="RadEditNodeName" DataTextField="Name"></telerik:RadTextBox>
                                    </td>
                                </tr>
                                <tr valign="top">
                                    <td>
                                        Node Server Details : 
                                    </td>
                                    <td>
                                        <telerik:RadTextBox runat="server" Text='<%#Bind("Notes") %>' 
                                         ID="RadEditNodeNotes" DataTextField="Notes"></telerik:RadTextBox>
                                    </td>
                                </tr>
                                <tr valign="top">
                                    <td colspan="2">
                                      <asp:Button ID="btnUpdate" Text="Update" runat="server" CausesValidation="False" CommandName="Update">
                                   </asp:Button>
                                   <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button>
                                    </td>
                                </tr>
                            </table>
                        </FormTemplate>
                    </EditFormSettings>
                </MasterTableView>
        </telerik:RadGrid>
<asp:HiddenField ID="GridEditableValue" runat="server" />
CS : 
        protected void Panel_Load(object sender, System.EventArgs e)
        {
            BTServerNode[] nodes = (BTServerNode[])ViewState["NODES"];

            if (nodes == null)
            {
                BTServerNodeFactory nodeFactory = new BTServerNodeFactory(ConnectionString);
                nodes = nodeFactory.GetNodesByCompany(AdminUser.CompanyID);
                ViewState["NODES"] = nodes;
            }

            RadGrid1.DataSource = nodes;
            RadGrid1.DataBind();
        }

        protected void companyGridUpdate(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName.Equals("Update"))
            {
                RadTextBox nameBox = (RadTextBox)e.Item.FindControl("RadEditNodeName");
                RadTextBox notesBox = (RadTextBox)e.Item.FindControl("RadEditNodeNotes");
                GridEditableValue.Value = nameBox.Text + ";" + notesBox.Text;
            }
        }

        protected void companyGridUpdated(object sender, Telerik.Web.UI.GridUpdatedEventArgs e)
        {
//TODO: save the values from GridEditableValue to db.
        }

5 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 05 Nov 2009, 07:17 AM
Hi,

I suspect that the events are not raised by the fact that you are rebinding the grid control on every postback. Please refer to our help documentation for more information on various ways to databind RadGrid (under Controls->RadGrid->Populating the control with data)

Regards,
Rosen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Princy
Top achievements
Rank 2
answered on 05 Nov 2009, 08:15 AM
Hi,

If you are updating your grid manually then you would have to set the AllowAutomaticUpdates property of the grid to false. Also the ItemUpdated event of the grid is meaningful only when you use automatic data editing operations via a DataSource control. Hence, if you prefer to manually update your grid items to the db you can review the following online demo(along with the help article linked under the Description tab):
Manual Update/Insert/Delete

Thanks
Princy.
0
gdr
Top achievements
Rank 1
answered on 05 Nov 2009, 03:26 PM
Well, nothing worked for me. i used the AllowAutomaticUpdates = false and OnNeedDataSource like
the examples .... still the event not firing ...

        protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            // Get Node Servers.
            BTServerNodeFactory nodeFactory = new BTServerNodeFactory(ConnectionString);
            BTServerNode[] nodes = nodeFactory.GetNodesByCompany(AdminUser.CompanyID);
            RadGrid1.DataSource = nodes;
        }
0
Shinu
Top achievements
Rank 2
answered on 06 Nov 2009, 08:33 AM
Hi,

The RadGrid doesn't support mixing of simple data-binding mode with advanced data-binding . Could you make sure that you are not implementing the Panel_Load event to bind the grid using DataBind along with the NeedDataSource event.You can call Rebind () in order  to rebind the grid on a postback

Thanks,
Shinu

0
Jai
Top achievements
Rank 1
answered on 06 Sep 2011, 01:42 PM
Hi Shinu,

On a specific ascx i have RadGrid and on that RadGrid, i have one Update button on Grid Header. And i have 2 columns in grid. In first Column i have data and second column i have check box against perticular row. Now When i checked any check box in grid and click on Update button, the OnUpdateCommand not firing. I saw lot of question regarding this on forum as well as i followed the following link that you have suggested (http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/extractvalues/defaultcs.aspx)  but didn't get success.I have follwoing Grid
<telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" OnUpdateCommand="RadGrid1_UpdateCommand" OnNeedDataSource="RadGrid1_NeedDataSource"
 
        EnableViewState="true" ClientIDMode="AutoID">
 
            <MasterTableView AutoGenerateColumns="False" EditMode="InPlace" CommandItemDisplay="Top"
 
                PageSize="10">
 
                <RowIndicatorColumn>
 
                    <HeaderStyle Width="20px"></HeaderStyle>
 
                </RowIndicatorColumn>
 
                <ExpandCollapseColumn>
 
                    <HeaderStyle Width="20px"></HeaderStyle>
 
                </ExpandCollapseColumn>
 
                <CommandItemTemplate>
 
                    <div style="float: right; font-size: medium;">
 
                        <asp:Button ID="BtnCommand1" Text="Update" runat="server" CommandName="Update" CssClass="button">
 
                        </asp:Button>
 
                    </div>
 
                </CommandItemTemplate>
 
                <Columns>
 
                    <telerik:GridTemplateColumn HeaderText="Flag" UniqueName="ABC" SortExpression="ABC">
 
                        <HeaderTemplate>
 
                            Access Flag
 
                            <asp:CheckBox ID="chkSelectAll" runat="server" OnCheckedChanged="chkSelectAll_CheckedChanged"
 
                                AutoPostBack="true" ToolTip="Select All" />
 
                        </HeaderTemplate>
 
                        <ItemTemplate>
 
                            <asp:CheckBox ID="chkboxaccess1" runat="server" Checked='<%#Convert.ToBoolean(Eval("Flag")) %>' />
 
                        </ItemTemplate>
 
                    </telerik:GridTemplateColumn>
 
                </Columns>
 
            </MasterTableView>
 
        </telerik:RadGrid>

Can you tell me Why the RadGrid update command not firing ? I have RadScript Manager on my Master page.

Thanks,
--Jai
Tags
Grid
Asked by
gdr
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Princy
Top achievements
Rank 2
gdr
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Jai
Top achievements
Rank 1
Share this question
or