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

Not getting expected result while deleting from Grid

1 Answer 35 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Subham
Top achievements
Rank 1
Subham asked on 31 Jul 2018, 03:48 PM

Hi there,

     First let me show you my code first,

<!-- Page Content Body -->
    <div class="content mt-3">
        <div class="animated fadeIn">
            <div class="row">
                <div class="col-lg-12">
                    <div class="card">
                        <div class="card-header">
                            <h4>Language Settings</h4>
                        </div>
                        <div class="card-body">
                            <div class="row form-group">
                                <asp:Panel CssClass="col-sm-12" ID="pnlMessage" runat="server">
                                    <div class="alert  alert-success alert-dismissible fade show" role="alert">
                                        <span class="badge badge-pill" id="message_header"> <!-- add badge-[type] for changing notification style -->
                                            <asp:Label runat="server" ID="lbl_type"></asp:Label></span>
                                        <asp:Label runat="server" ID="lblMessage"></asp:Label>
                                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                            <span aria-hidden="true">×</span>
                                        </button>
                                    </div>
                                </asp:Panel>
                            </div>
                            <div class="row form-group">
                                <div class="col-md-6">
                                    <div class="row">
                                        <div class="col-md-5">
                                            <asp:Label ID="label" AssociatedControlID="txt_languageName" Text="Enter language Name" runat="server" />
                                        </div>
                                        <div class="col-md-7">
                                            <telerik:RadTextBox runat="server" ID="txt_languageName" Skin="Glow" RenderMode="Lightweight" Width="100%">
                                                <EnabledStyle BackColor="#FFFFFF" ForeColor="Black"></EnabledStyle>
                                                <FocusedStyle BackColor="Black" ForeColor="#FFFFFF"></FocusedStyle>
                                                <HoveredStyle BackColor="Black" ForeColor="#FFFFFF"></HoveredStyle>
                                            </telerik:RadTextBox>
                                            <small class="form-text text-muted hide_me">This is a help text</small>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="row">
                                        <div class="col-md-5">
                                            <asp:Label ID="label1" AssociatedControlID="txt_langCode" Text="Enter language Code" runat="server" />
                                        </div>
                                        <div class="col-md-7">
                                            <telerik:RadTextBox runat="server" ID="txt_langCode" Width="100%" Skin="Glow" RenderMode="Lightweight">
                                                <EnabledStyle BackColor="#FFFFFF" ForeColor="Black"></EnabledStyle>
                                                <FocusedStyle BackColor="Black" ForeColor="#FFFFFF"></FocusedStyle>
                                                <HoveredStyle BackColor="Black" ForeColor="#FFFFFF"></HoveredStyle>
                                            </telerik:RadTextBox>
                                            <small class="form-text text-muted hide_me">This is a help text</small>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- second row -->
                            <div class="row form-group">
                                <div class="col-md-6">
                                    <div class="row">
                                        <div class="col-md-5">
                                            <asp:Label ID="label2" AssociatedControlID="txt_languageName" Text="Enter Culture Code" runat="server" />
                                        </div>
                                        <div class="col-md-7">
                                            <telerik:RadTextBox runat="server" ID="txt_culture_code" Skin="Glow" RenderMode="Lightweight" Width="100%">
                                                <EnabledStyle BackColor="#FFFFFF" ForeColor="Black"></EnabledStyle>
                                                <FocusedStyle BackColor="Black" ForeColor="#FFFFFF"></FocusedStyle>
                                                <HoveredStyle BackColor="Black" ForeColor="#FFFFFF"></HoveredStyle>
                                            </telerik:RadTextBox>
                                            <small class="form-text text-muted hide_me">This is a help text</small>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="row">
                                        <div class="col-md-5">
                                            <asp:Label ID="label3" AssociatedControlID="txt_isoValue" Text="Enter ISO Code" runat="server" />
                                        </div>
                                        <div class="col-md-7">
                                            <telerik:RadTextBox runat="server" ID="txt_isoValue" Width="100%" Skin="Glow" RenderMode="Lightweight">
                                                <EnabledStyle BackColor="#FFFFFF" ForeColor="Black"></EnabledStyle>
                                                <FocusedStyle BackColor="Black" ForeColor="#FFFFFF"></FocusedStyle>
                                                <HoveredStyle BackColor="Black" ForeColor="#FFFFFF"></HoveredStyle>
                                            </telerik:RadTextBox>
                                            <small class="form-text text-muted hide_me">This is a help text</small>
                                        </div>
                                    </div>
                                </div>
                            </div>
 
                            <!-- third row -->
                            <div class="row form-group">
                                <div class="col-md-12 headerClass">
                                    <div class="btn-group">
                                        <asp:Button runat="server" ID="btnSave" Text="Save" Width="53%" OnClick="btnSave_OnClick" CssClass="w3-btn" />
                                        <asp:Button runat="server" ID="btnSearch" Text="Search" Width="53%" OnClick="btnSearch_OnClick" CssClass="w3-btn" />
                                    </div>
                                </div>
                            </div>
 
                            <!-- show hide radgrid -->
                            <div class="row form-group">
                                <div class="col-md-12">
                                    <telerik:RadGrid runat="server" ID="radGridLanguage" AutoGenerateColumns="False" BorderStyle="None" AllowPaging="True"
                                        AllowSorting="True" OnItemCommand="radGridLanguage_ItemCommand" PageSize="10" RenderMode="Lightweight" Skin="Glow"
                                        Style="margin-top: 1%; width: 98%; font-size: 13px">
                                        <MasterTableView AllowFilteringByColumn="True" NoMasterRecordsText="No language data found" Height="10px" BackColor="#272c33" FilterItemStyle-BorderColor="white">
                                            <Columns>
                                                <telerik:GridBoundColumn DataField="lang_name" FilterControlAltText="Filter column column" HeaderText="Language Name" UniqueName="column" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="culture_name" FilterControlAltText="Filter column1 column" HeaderText="Culture Name" UniqueName="column1" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="culture_code" FilterControlAltText="Filter column2 column" HeaderText="Culture Code" UniqueName="column2" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="iso_639x_value" FilterControlAltText="Filter column3 column" HeaderText="ISO Value" UniqueName="column3" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridTemplateColumn HeaderText="Action" AllowFiltering="false">
                                                    <ItemTemplate>
                                                        <asp:Label ID="lblLangAutoId" Text='<%#Eval("autoid") %>' runat="server" Visible="false"></asp:Label>
                                                        <asp:ImageButton ID="imgBtnDelLanguage" runat="server" Width="20px" ImageUrl="~/Images/delete.png" OnClick="imgBtnDelLanguage_OnClick" OnClientClick="return confirm('want to delete?');" />
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>
                                            </Columns>
                                        </MasterTableView>
                                        <PagerStyle Mode="NextPrevAndNumeric" />
                                        <GroupingSettings CollapseAllTooltip="Collapse all groups" />
                                        <HeaderStyle BackColor="#272c33" Font-Bold="True" BorderColor="white" />
                                    </telerik:RadGrid>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
 
    <!-- set ajaxify -->
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="lp" ShowLoadingPanelForPostBackControls="True" UpdatePanelsRenderMode="Inline">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="btnSearch">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="radGridLanguage" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
 
    <telerik:RadAjaxLoadingPanel ID="lp" runat="server" Transparency="30" MinDisplayTime="300" EnableEmbeddedSkins="False">
        <div class="loading">
            <asp:Image ID="Image1" runat="server" ImageUrl="../../Images/loading-default.gif" AlternateText="loading"></asp:Image>
        </div>
    </telerik:RadAjaxLoadingPanel>

 

Now as you could see, I have four text box controls two button controls(Save,Search) and one grid and one panel control present in page.

Flow:

 Now as mentioned previously two buttons are save and search.

  1.  When User fill up the form and click on Save button data will store into database and after that panel will be popped up describing status message.(done)
  2.  Now, while user clicks on Search button grid will appear. (done)
  3. Now while user clicks on the delete button, data gets deleted , but that panel is not showing up.(Not Done)
  4. After clicking on the delete button I want to reset my controls (textbox) . (Not done)
 
protected void btnSave_OnClick(object sender, EventArgs e)
        {
            pnlMessage.Visible = true;
            _objBelAdministration.flag = "insert";
            _objBelAdministration.strLanguageName = txt_languageName.Text.Trim();
            _objBelAdministration.strCultureName = txt_langCode.Text.Trim();
            _objBelAdministration.strCultureCode = txt_culture_code.Text.Trim();
            _objBelAdministration.strIsoValue = txt_isoValue.Text.Trim();
            if ((_objBlAdministration.InsertLanguageInfo(_objBelAdministration)) > 0)
            {
                lbl_type.Text = "Sucess";
                lblMessage.Text = "Sucessfully inserted into database";
                ScriptManager.RegisterStartupScript(this.Page, typeof(Type), "alert01", "addClassSucess();", true);
            }
            else
            {
                lbl_type.Text = "Failure!";
                lblMessage.Text = "Problem while inserting into database";
                ScriptManager.RegisterStartupScript(this.Page, typeof(Type), "alert012", "addClassDanger();", true);
            }
            GetLanguages();
        }
 
 
 
protected void imgBtnDelLanguage_OnClick(object sender, ImageClickEventArgs e)
        {
            pnlMessage.Visible = true;
            var button = (ImageButton)sender;
            var item = (GridDataItem)(button.NamingContainer);
            _objBelAdministration.flag = "delete";
            _objBelAdministration.autoid = ((Label)(item.FindControl("lblLangAutoId"))).Text;
            if (_objBlAdministration.DeleteLanguageInfo(_objBelAdministration) > 0)
            {
                lbl_type.Text = "Sucess";
                lblMessage.Text = "Deleted from database";
                ScriptManager.RegisterStartupScript(this.Page, typeof(Type), "alert01", "addClassSucess();", true);
            }
            else
            {
                lbl_type.Text = "Error";
                lblMessage.Text = "Error ocured when Deleting from database";
                ScriptManager.RegisterStartupScript(this.Page, typeof(Type), "alert01", "addClassSucess();", true);
            }
            ResetControls();
            GetLanguages();
        }
 
        private void ResetControls()
        {
            txt_languageName.Text = "";
            txt_langCode.Text = "";
            txt_culture_code.Text = "";
            txt_isoValue.Text = "";
        }

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 03 Aug 2018, 08:43 AM
Hi Subham,

The remaining issues may be related to AJAX. You can temporarily remove it to achieve the remaining steps from your list:
https://www.telerik.com/support/kb/aspnet-ajax/ajaxmanager/details/get-more-descriptive-errors-by-disabling-ajax

Once the application works as expected, you can turn AJAX back on and add the respective control IDs to the AjaxSettings to resolve this use so that the combo will update and reset the controls accordingly. Also, the radGridLanguage grid should update itself.

I hope this will prove helpful. Please give the provided suggestions a try and let us know about the result.

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Ajax
Asked by
Subham
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or