Grid inside PanelBar can handle ItemDelete?

3 posts, 1 answers
  1. Carlos
    Carlos avatar
    7 posts
    Member since:
    Aug 2011

    Posted 09 Nov 2011 Link to this post

    Hi,

    I try to handle the error in delete action, when clicked delete button,  but i can't handle radgrid_itemDeleted, visual studio shows the error.

    for example

    <telerik:RadPanelBar ID="RadPanelBar1" runat="server" ExpandMode="SingleExpandedItem"
                Width="1102px" Skin="Vista" AllowCollapseAllItems="true"  >
                <CollapseAnimation Type="None"></CollapseAnimation>
                <Items>
                    <telerik:RadPanelItem runat="server" Text="Objectives Parameters" Expanded="true">
                        <Items>
                            <telerik:RadPanelItem Text="" Value="PanelItemObjParameters">
                                <ItemTemplate>
                                    <telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
                                        AllowAutomaticUpdates="True" AllowPaging="True" AutoGenerateColumns="False" AutoGenerateDeleteColumn="True"
                                        AutoGenerateEditColumn="True" CellSpacing="0" DataSourceID="ObjectiveParameterDataSource"
                                        GridLines="None" >
                                        <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
                                        </HeaderContextMenu>
                                        <MasterTableView DataKeyNames="objective_parameter_id" DataSourceID="ObjectiveParameterDataSource"
                                            CommandItemDisplay="Top">
                                            <CommandItemSettings ExportToPdfText="Export to PDF" />
                                            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                                                <HeaderStyle Width="20px" />
                                            </RowIndicatorColumn>
                                            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                                                <HeaderStyle Width="20px" />
                                            </ExpandCollapseColumn>
                                            <Columns>
                                                <telerik:GridBoundColumn DataField="objective_parameter_id" DataType="System.Int32"
                                                    FilterControlAltText="Filter objective_parameter_id column" HeaderText="Id" ReadOnly="True"
                                                    SortExpression="objective_parameter_id" UniqueName="objective_parameter_id">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridDropDownColumn DataField="objective_id" DataSourceID="ObjectiveDataSource"
                                                    HeaderText="Objective" ListTextField="objective_name" ListValueField="objective_id"
                                                    UniqueName="objective_id" ColumnEditorID="GridDropDownColumnEditorAdm1">
                                                </telerik:GridDropDownColumn>
                                                <telerik:GridTemplateColumn DataField="field_name" FilterControlAltText="Filter field_name column"
                                                    HeaderText="Field Name" SortExpression="field_name" UniqueName="field_name">
                                                    <EditItemTemplate>
                                                        <asp:TextBox ID="field_nameTextBox" runat="server" Text='<%# Bind("field_name") %>'></asp:TextBox>
                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="field_nameTextBox"
                                                            ErrorMessage="*"></asp:RequiredFieldValidator>
                                                    </EditItemTemplate>
                                                    <ItemTemplate>
                                                        <asp:Label ID="field_nameLabel" runat="server" Text='<%# Eval("field_name") %>'></asp:Label>
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>
                                            </Columns>
                                            <EditFormSettings>
                                                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                                                </EditColumn>
                                            </EditFormSettings>
                                        </MasterTableView>
                                        <FilterMenu EnableImageSprites="False">
                                        </FilterMenu>
                                    </telerik:RadGrid>
                                </ItemTemplate>
                            </telerik:RadPanelItem>
                        </Items>
                    </telerik:RadPanelItem>

    And code behind is: the error is not recognized the handles RadGrid1.

    Protected Sub RadGrid1_ItemDeleted(ByVal source As Object, ByVal e As Telerik.Web.UI.GridDeletedEventArgs) Handles RadGrid1.ItemDeleted
            Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
            Dim id As String = item.GetDataKeyValue("objective_parameter_id").ToString()
     
            If Not e.Exception Is Nothing Then
                e.ExceptionHandled = True
                SetMessage("Objective Type with ID " + id + " cannot be deleted. Reason: " + e.Exception.Message)
            Else
                SetMessage("Objective Type with ID " + id + " is deleted!")
            End If
        End Sub


    Can help me?
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 09 Nov 2011 Link to this post

    Hello Carlos,

    Make sure that you have attached the event ItemDeleted to the RadGrid in the aspx page as shown below.
    aspx:
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="false"  AllowPaging="True" AutoGenerateColumns="False"AutoGenerateDeleteColumn="true"
    AutoGenerateEditColumn="True" onitemdeleted="RadGrid1_ItemDeleted"  CellSpacing="0" DataSourceID="SqlDataSource1"GridLines="None"  >
    </telerik:RadGrid>

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Carlos
    Carlos avatar
    7 posts
    Member since:
    Aug 2011

    Posted 10 Nov 2011 Link to this post

    Thanks

    for you reply and solution.
Back to Top