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

[Solved] RADGrid OnItemUpdated does not fire

5 Answers 552 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 01 Sep 2009, 08:05 PM
Hi,
I cannot get the OnItemUpdated command to fire for the code given below.


        <radG:RadGrid id="MakerGrid" OnItemUpdated="MakerGrid_ItemUpdated" ShowStatusBar="true" OnItemInserted="MakerGrid_ItemInserted" 
            EnableAJAX="False" AllowAutomaticDeletes="True" AllowAutomaticUpdates="True" runat="server" 
            Skin="Default2006" AllowSorting="True" PageSize="15" ShowFooter="True" AllowPaging="True">  
            <PagerStyle CssClass="GridPager_Default GridPager_"></PagerStyle>  
            <AlternatingItemStyle CssClass="GridAltRow_Default GridAltRow_"></AlternatingItemStyle>  
            <GroupHeaderItemStyle CssClass="GroupHeader_Default GroupHeader_"></GroupHeaderItemStyle>  
            <FilterMenu NotSelectedImageUrl="~/RadControls/Grid/Skins/Default/NotSelectedMenu.gif" SelectedImageUrl="~/RadControls/Grid/Skins/Default/SelectedMenu.gif"></FilterMenu>  
            <MasterTableView EditMode="InPlace" CommandItemDisplay="None" AutoGenerateColumns="False" CssClass="MasterTable_Default MasterTable_">  
                <RowIndicatorColumn Visible="False">  
                    <ItemStyle CssClass="ResizeItem_Default ResizeItem_"></ItemStyle>  
                    <HeaderStyle Width="20px" CssClass="ResizeHeader_Default ResizeHeader_"></HeaderStyle>  
                </RowIndicatorColumn>  
                <EditFormSettings>  
                    <EditColumn UniqueName="EditCommandColumn1"></EditColumn>  
                </EditFormSettings>  
                <Columns>  
                    <radg:GridHyperLinkColumn UniqueName="linkColumn" NavigateURL="" Target="_blank" Text="<img border='0' alt='Open Amendment' src='../../common/bookimages/open_book.gif'>"></radg:GridHyperLinkColumn>  
                    <radg:GridBoundColumn DataField="fkMaker" UniqueName="fkMaker" Display="False"></radg:GridBoundColumn>  
                    <radg:GridBoundColumn HeaderText="Precis" DataField="precis" UniqueName="Precis"></radg:GridBoundColumn>  
                    <radg:GridBoundColumn HeaderText="Description" DataField="description" UniqueName="Description"></radg:GridBoundColumn>  
                    <radg:GridBoundColumn HeaderText="Status" DataField="status" UniqueName="Status"></radg:GridBoundColumn>  
                    <radg:GridBoundColumn HeaderText="cleaned" DataField="cleaned" UniqueName="cleaned" visible="false"></radg:GridBoundColumn>  
                    <radg:GridBoundColumn HeaderText="Date Created" DataField="DateCreated" ReadOnly="True" UniqueName="DateCreated"></radg:GridBoundColumn>  
                    <radg:GridBoundColumn HeaderText="Who Created" DataField="WhoCreated" UniqueName="WhoCreated"></radg:GridBoundColumn>  
                    <radg:GridEditCommandColumn HeaderText="Edit" UpdateImageUrl="../../../common/baseimages/apply.gif" InsertImageUrl="../../../common/baseimages/apply.gif" 
                        EditImageUrl="../../../common/controlimages/gredit.gif" ButtonType="ImageButton" CancelImageUrl="../../../common/baseimages/cancel.gif" UniqueName="EditColumn">  
                        <ItemStyle HorizontalAlign="Center" CssClass="gridButton"></ItemStyle>  
                    </radg:GridEditCommandColumn>  
                    <radg:GridButtonColumn HeaderText="Delete" ImageUrl="../../../common/baseimages/trash.gif" CommandName="Delete" ConfirmText="Delete this package?" 
                        ButtonType="ImageButton" Text="Delete" UniqueName="DeleteColumn">  
                        <ItemStyle HorizontalAlign="Center" CssClass="gridButton"></ItemStyle>  
                        <HeaderStyle Width="20px"></HeaderStyle>  
                    </radg:GridButtonColumn>  
                    <radg:GridButtonColumn HeaderText="Clean" CommandName="Clean" ConfirmText="Clean this amendment package for publishing?" ImageUrl="../../../common/baseimages/discuss.gif" ButtonType="ImageButton" Text="Clean this amendment" UniqueName="CleanAm">  
                        <ItemStyle HorizontalAlign="Center" CssClass="gridButton"></ItemStyle>  
                        <ItemStyle HorizontalAlign="Center" ></ItemStyle>  
                    </radg:GridButtonColumn>  
                    <radg:GridButtonColumn HeaderText="In Force" CommandName="Enforce" ConfirmText="Enforce this amendment package?" ImageUrl="../../common/treeimages/page_cross_red.gif" ButtonType="ImageButton" Text="Enforce this amendment" UniqueName="EnforceColumn">  
                        <ItemStyle HorizontalAlign="Center" ></ItemStyle>  
                    </radg:GridButtonColumn>  
                    <radg:GridBoundColumn HeaderText="Date In Force" DataField="DateModified" UniqueName="DateInForce"></radg:GridBoundColumn>  
                    <radg:GridHyperLinkColumn HeaderText="E-Plan" UniqueName="ePlan" NavigateURL="" Target="_blank" Text="<img border='0' alt='Draft E-Plan' src='./../../common/baseimages/amendments/draft.gif' width='24px'>">  
                        <ItemStyle HorizontalAlign="Center" ></ItemStyle>  
                    </radg:GridHyperLinkColumn>  
                    <radg:GridHyperLinkColumn HeaderText="Current" UniqueName="Current" NavigateURL="" Target="_blank" Text="<img border='0' alt='Current Version Detail Report' src='./../../common/baseimages/amendments/view_detail.gif' width='24px'>">  
                        <ItemStyle HorizontalAlign="Center" ></ItemStyle>  
                    </radg:GridHyperLinkColumn>   
                              
                </Columns>  
                <ExpandCollapseColumn Visible="False">  
                    <HeaderStyle Width="19px"></HeaderStyle>  
                </ExpandCollapseColumn>  
            </MasterTableView>  
            <HeaderStyle CssClass="GridHeader_Default GridHeader_"></HeaderStyle>  
            <SelectedItemStyle CssClass="SelectedRow_Default SelectedRow_"></SelectedItemStyle>  
            <ActiveItemStyle CssClass="ActiveRow_Default ActiveRow_"></ActiveItemStyle>  
            <ItemStyle CssClass="GridRow_Default GridRow_"></ItemStyle>  
            <FooterStyle CssClass="GridFooter_Default GridFooter_"></FooterStyle>  
        </radG:RadGrid>  
 

CODEBEHIND
    Public Sub MakerGrid_ItemUpdated(ByVal source As ObjectByVal e As Telerik.WebControls.GridUpdatedEventArgs) Handles MakerGrid.ItemUpdated  
 
        'Get the drop-down-list value  
        Dim dataEditItem As GridEditableItem = e.Item  
        Dim cID As String = CType(dataEditItem("fkMaker").Controls(0), TextBox).Text  
        Dim pM As New BRMaker  
        Dim dR As DataRow = pM.FillRow("SELECT * FROM mkMaker WHERE fkMaker=" & cID, AppSettings("connMP"))  
 
        dR("fkMaster") = 0 'Obselete  
 
        dR("WhoCreated") = CType(dataEditItem.Controls(9).Controls(0), TextBox).Text.TrimStart(" ").TrimEnd(" ")  
        dR("precis") = CType(dataEditItem.Controls(4).Controls(0), TextBox).Text  
        dR("Description") = CType(dataEditItem.Controls(5).Controls(0), TextBox).Text  
        dR("status") = CType(dataEditItem.Controls(6).Controls(1), DropDownList).SelectedValue  
 
        dR("DateModified") = DateTime.Now  
        dR("WhoModified") = Framework.Container.GetUser(Session, Request, AppSettings("MPTitle"), Framework.Container.GetAuthType(AppSettings("authorization")))  
        pM.SaveRow(dR, pM.GetDS, "Master")  
 
        If Not pM.Update(AppSettings("connMP"), pM.GetDS) Then 
            Log(AppSettings("MPlog"), "Amendments Error""Error updating mkMaker")  
        End If 
 
        pM.CloseRow()  
 
        MakerGrid.Columns(9).Visible = True 
        MakerGrid.Columns(10).Visible = True 
        MakerGrid.Columns(11).Visible = True 
        MakerGrid.Columns(12).Visible = True 
        MakerGrid.Columns(13).Visible = True 
        MakerGrid.Columns(14).Visible = True 
        BuildGrid()  
 
    End Sub 
 

Note:This was working in RADControls for ASP.NET RADGrid v5.1.3.0

Thanks and Regards



5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 02 Sep 2009, 06:13 AM
Hi,

ItemUpdated is applicable only when the grid is bound to DataSourceControl!

Greetings,
Vlad
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
Paul
Top achievements
Rank 1
answered on 02 Sep 2009, 06:57 AM
Thanks Vlad for the reply.

I have bound the grid to a DataSourceControl as given below.

    Private Sub BuildGrid() 
 
        Dim cSQL As String = "SELECT fkMaker, precis, description, status, cleaned, DateCreated, rtrim(WhoCreated) as whocreated, DateModified FROM mkMaker" 
        Dim ds As DataSet = Framework.Container.GetDataSet(cSQL, AppSettings("connMP")) 
 
        Dim vw As DataView = ds.Tables(0).DefaultView 
        MakerGrid.DataSource = vw 
        MakerGrid.DataBind() 
    End Sub 

Thanks...
0
Vlad
Telerik team
answered on 02 Sep 2009, 07:26 AM
Hi,

Actually I'm referring to controls like SqlDataSource, ObjectDataSource, LinqDataSource, EntityDataSource, etc.

Kind regards,
Vlad
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
Paul
Top achievements
Rank 1
answered on 02 Sep 2009, 10:55 AM
OK.I have done a work around for OnItemUpdated command.
I have mapped OnUpdateCommand="MakerGrid_UpdateCommand" in the datagrid statically.
And I do the database updates in MakerGrid_UpdateCommand function.
The database updates are success but the grid still remains in Edit mode after update.

Already tried
  • remove RADAjaxpanel - same result

Code for Grid declaration is given below.
<telerik:RadAjaxPanel id="Radajaxpanel1" runat="server"
        <telerik:RadGrid id="MakerGrid" ShowStatusBar="true" OnItemInserted="MakerGrid_ItemInserted" 
            EnableAJAX="False" AllowAutomaticDeletes="True" AllowAutomaticUpdates="True" runat="server" 
            Skin="Default" AllowSorting="True" PageSize="15" ShowFooter="True" AllowPaging="True" OnUpdateCommand="MakerGrid_UpdateCommand"
            <MasterTableView EditMode="InPlace" CommandItemDisplay="None" AutoGenerateColumns="False"
                <RowIndicatorColumn Visible="False"
                    <HeaderStyle Width="20px"></HeaderStyle> 
                </RowIndicatorColumn> 
                <EditFormSettings> 
                    <EditColumn UniqueName="EditCommandColumn1"></EditColumn> 
                </EditFormSettings> 
                <Columns> 
                    <telerik:GridHyperLinkColumn UniqueName="linkColumn" NavigateURL="" Target="_blank" Text="<img border='0' alt='Open Amendment' src='../../common/bookimages/open_book.gif'>"></telerik:GridHyperLinkColumn> 
                    <telerik:GridBoundColumn DataField="fkMaker" UniqueName="fkMaker" Display="False"></telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn HeaderText="Precis" DataField="precis" UniqueName="Precis"></telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn HeaderText="Description" DataField="description" UniqueName="Description"></telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn HeaderText="Status" DataField="status" UniqueName="Status"></telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn HeaderText="cleaned" DataField="cleaned" UniqueName="cleaned" visible="false"></telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn HeaderText="Date Created" DataField="DateCreated" ReadOnly="True" UniqueName="DateCreated"></telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn HeaderText="Who Created" DataField="WhoCreated" UniqueName="WhoCreated"></telerik:GridBoundColumn> 
                    <telerik:GridEditCommandColumn HeaderText="Edit" UpdateImageUrl="../../../common/baseimages/apply.gif" InsertImageUrl="../../../common/baseimages/apply.gif" 
                        EditImageUrl="../../../common/controlimages/gredit.gif" ButtonType="ImageButton" CancelImageUrl="../../../common/baseimages/cancel.gif" UniqueName="EditColumn"
                        <ItemStyle HorizontalAlign="Center"></ItemStyle> 
                    </telerik:GridEditCommandColumn> 
                    <telerik:GridButtonColumn HeaderText="Delete" ImageUrl="../../../common/baseimages/trash.gif" CommandName="Delete" ConfirmText="Delete this package?" 
                        ButtonType="ImageButton" Text="Delete" UniqueName="DeleteColumn"
                        <ItemStyle HorizontalAlign="Center" ></ItemStyle
                        <HeaderStyle Width="20px"></HeaderStyle> 
                    </telerik:GridButtonColumn> 
                    <telerik:GridButtonColumn HeaderText="Clean" CommandName="Clean" ConfirmText="Clean this amendment package for publishing?" ImageUrl="../../../common/baseimages/discuss.gif" ButtonType="ImageButton" Text="Clean this amendment" UniqueName="CleanAm"
                        <ItemStyle HorizontalAlign="Center"></ItemStyle> 
                        <ItemStyle HorizontalAlign="Center" ></ItemStyle
                    </telerik:GridButtonColumn> 
                    <telerik:GridButtonColumn HeaderText="In Force" CommandName="Enforce" ConfirmText="Enforce this amendment package?" ImageUrl="../../common/treeimages/page_cross_red.gif" ButtonType="ImageButton" Text="Enforce this amendment" UniqueName="EnforceColumn"
                        <ItemStyle HorizontalAlign="Center" ></ItemStyle
                    </telerik:GridButtonColumn> 
                    <telerik:GridBoundColumn HeaderText="Date In Force" DataField="DateModified" UniqueName="DateInForce"></telerik:GridBoundColumn> 
                    <telerik:GridHyperLinkColumn HeaderText="E-Plan" UniqueName="ePlan" NavigateURL="" Target="_blank" Text="<img border='0' alt='Draft E-Plan' src='./../../common/baseimages/amendments/draft.gif' width='24px'>"
                        <ItemStyle HorizontalAlign="Center" ></ItemStyle
                    </telerik:GridHyperLinkColumn> 
                    <telerik:GridHyperLinkColumn HeaderText="Current" UniqueName="Current" NavigateURL="" Target="_blank" Text="<img border='0' alt='Current Version Detail Report' src='./../../common/baseimages/amendments/view_detail.gif' width='24px'>"
                        <ItemStyle HorizontalAlign="Center" ></ItemStyle
                    </telerik:GridHyperLinkColumn>   
                </Columns> 
                <ExpandCollapseColumn Visible="False"
                    <HeaderStyle Width="19px"></HeaderStyle> 
                </ExpandCollapseColumn> 
            </MasterTableView> 
        </telerik:RadGrid> 
</telerik:RadAjaxPanel> 
 

Code for Page_Load
    Private Sub Page_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load 
        Try 
            BuildGrid() 
        Catch ex As Exception 
            Log(AppSettings("MPlog"), "Amendments Error""Maker List Table does not exist"
        End Try 
    End Sub 
 

BuildGrid function
    Private Sub BuildGrid() 
 
        Dim cSQL As String = "SELECT fkMaker, precis, description, status, cleaned, DateCreated, rtrim(WhoCreated) as whocreated, DateModified FROM mkMaker" 
        Dim ds As DataSet = Framework.Container.GetDataSet(cSQL, AppSettings("connMP")) 
 
        Dim vw As DataView = ds.Tables(0).DefaultView 
        MakerGrid.DataSource = vw 
        MakerGrid.DataBind() 
 
 
    End Sub 


UpdateGrid function
    Protected Sub MakerGrid_UpdateCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) 
 
        'Get the drop-down-list value 
        Dim dataEditItem As GridEditableItem = e.Item 
        Dim cID As String = CType(dataEditItem("fkMaker").Controls(0), TextBox).Text 
        Dim pM As New BRMaker 
        Dim dR As DataRow = pM.FillRow("SELECT * FROM mkMaker WHERE fkMaker=" & cID, AppSettings("connMP")) 
 
        dR("fkMaster") = 0 'Obselete 
 
        dR("WhoCreated") = CType(dataEditItem.Controls(9).Controls(0), TextBox).Text.TrimStart(" ").TrimEnd(" "
        dR("precis") = CType(dataEditItem.Controls(4).Controls(0), TextBox).Text 
        dR("Description") = CType(dataEditItem.Controls(5).Controls(0), TextBox).Text 
        dR("status") = CType(dataEditItem.Controls(6).Controls(1), DropDownList).SelectedValue 
 
        dR("DateModified") = DateTime.Now 
        dR("WhoModified") = Framework.Container.GetUser(Session, Request, AppSettings("MPTitle"), Framework.Container.GetAuthType(AppSettings("authorization"))) 
        pM.SaveRow(dR, pM.GetDS, "Master"
 
        If Not pM.Update(AppSettings("connMP"), pM.GetDS) Then 
            Log(AppSettings("MPlog"), "Amendments Error""Error updating mkMaker"
        End If 
 
        pM.CloseRow() 
 
        BuildGrid() 
 
        MakerGrid.Columns(9).Visible = False 
        MakerGrid.Columns(10).Visible = False 
        MakerGrid.Columns(11).Visible = False 
        MakerGrid.Columns(12).Visible = False 
        MakerGrid.Columns(13).Visible = False 
        MakerGrid.Columns(14).Visible = False 
    End Sub 
 



0
Accepted
Sebastian
Telerik team
answered on 02 Sep 2009, 11:04 AM
Hello Andy,

You need to set the AllowAutomaticXXXX properties of the grid/master table to false since they are applicable for automatic data editing operations only. Otherwise the edit/insert form of the control will remain open.

Regards,
Sebastian
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.
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Paul
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or