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

Editing on filtered radgrid

1 Answer 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Coskun Ince
Top achievements
Rank 2
Coskun Ince asked on 08 Apr 2010, 11:29 AM
When i want to edit a row in a filtered radgrid, it returns me the data of another line. Apparently filtering disappears when i click the edit button, thus the line with that pageindex and itemindex on unfiltered grid. how can i solve this problem?

aspx:

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1" 
                    EnableAJAX="true"
                    <telerik:RadGrid BorderWidth="0" ID="gridResult" runat="server" AutoGenerateColumns="False" 
                        Width="100%" Height="480px" AllowSorting="True" AllowPaging="true" PageSize="25" 
                        Skin="Hay" OnUpdateCommand="gridResult_UpdateCommand" OnDeleteCommand="gridResult_DeleteCommand" OnItemDataBound="gridResult_OnItemDataBound" 
                        OnInsertCommand="gridResult_InsertCommand" OnNeedDataSource="gridResult_NeedDataSource" AllowFilteringByColumn="true"
                        <MasterTableView EditMode="InPlace" CommandItemDisplay="Top" ShowHeadersWhenNoRecords="true"  
                            AllowNaturalSort="true" AllowMultiColumnSorting="true" Font-Names="Tahoma"
                            <Columns> 
                                <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditColumn" HeaderStyle-Width="20px" 
                                    CancelText="İptal" EditText="Düzenle" InsertText="Kaydet" UpdateText="Güncelle"
                                </telerik:GridEditCommandColumn> 
                                <telerik:GridTemplateColumn DataField="NO" HeaderText="No" Visible="false" HeaderStyle-Width="20px" 
                                    SortExpression="NO"
                                    <ItemTemplate> 
                                        <asp:Label ID="lblNo" runat="server" Text='<%# Bind("NO") %>'></asp:Label> 
                                    </ItemTemplate> 
                                </telerik:GridTemplateColumn> 
                                <telerik:GridTemplateColumn DataField="AD" HeaderText="Parametre Adı" SortExpression="AD" 
                                    HeaderStyle-Width="75px" ShowFilterIcon="false" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true"
                                    <EditItemTemplate> 
                                        <telerik:RadTextBox ID="txtAd" runat="server" Text='<%# Bind("AD") %>' Width="75px" 
                                            SelectionOnFocus="CaretToEnd"
                                        </telerik:RadTextBox> 
                                        <asp:RequiredFieldValidator ID="rfvAd" runat="server" ControlToValidate="txtAd" Display="Dynamic" 
                                            ErrorMessage="Parametre adı girilmek zorundadır."></asp:RequiredFieldValidator> 
                                    </EditItemTemplate> 
                                    <ItemTemplate> 
                                        <asp:Label ID="lblAd" runat="server" Text='<%# Bind("AD") %>'></asp:Label> 
                                    </ItemTemplate> 
                                </telerik:GridTemplateColumn> 
                                <telerik:GridTemplateColumn DataField="ACIKLAMA" HeaderText="Açıklama" HeaderStyle-Width="100px" 
                                    SortExpression="ACIKLAMA" AllowFiltering="false"
                                    <EditItemTemplate> 
                                        <telerik:RadTextBox ID="txtAciklama" runat="server" Text='<%# Bind("ACIKLAMA") %>' 
                                            TextMode="MultiLine" Rows="4" Width="100px" SelectionOnFocus="CaretToEnd"
                                        </telerik:RadTextBox> 
                                        <asp:RequiredFieldValidator ID="rfvAciklama" runat="server" ControlToValidate="txtAciklama" 
                                            Display="Dynamic" ErrorMessage="Parametre açıklaması girilmek zorundadır."></asp:RequiredFieldValidator> 
                                    </EditItemTemplate> 
                                    <ItemTemplate> 
                                        <asp:Label ID="lblAciklama" runat="server" Text='<%# Bind("ACIKLAMA") %>'
                                        </asp:Label> 
                                    </ItemTemplate> 
                                </telerik:GridTemplateColumn> 
                                <telerik:GridTemplateColumn DataField="GRUBU" HeaderText="Grubu" SortExpression="GRUBU" 
                                    HeaderStyle-Width="75px" ShowFilterIcon="false" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true"
                                    <EditItemTemplate> 
                                        <telerik:RadComboBox ID="ddlGrubu" runat="server" SelectedValue='<%# Bind("GRUBU") %>' 
                                            Width="75px"
                                            <Items> 
                                                <telerik:RadComboBoxItem runat="server" Text="Seçiniz" Value="-1" /> 
                                                <telerik:RadComboBoxItem runat="server" Text="A" Value="A" /> 
                                                <telerik:RadComboBoxItem runat="server" Text="B" Value="B" /> 
                                                <telerik:RadComboBoxItem runat="server" Text="C" Value="C" /> 
                                                <telerik:RadComboBoxItem runat="server" Text="D" Value="D" /> 
                                                <telerik:RadComboBoxItem runat="server" Text="Diğer" Value="-"/> 
                                            </Items> 
                                        </telerik:RadComboBox> 
                                        <%--<dsi:MultipleListControl ID="ddlGrubu" runat="server"/>--%> 
                                        <%--<asp:RequiredFieldValidator ID="rfvGrubu" runat="server" ControlToValidate="ddlGrubu" 
                                            Display="Dynamic" ErrorMessage="Parametre grubu seçilmek zorundadır." InitialValue="Seçiniz"
                                        </asp:RequiredFieldValidator>--%> 
                                    </EditItemTemplate> 
                                    <ItemTemplate> 
                                        <asp:Label ID="lblGrubu" runat="server" Text='<%# Bind("GRUBU") %>'></asp:Label> 
                                    </ItemTemplate> 
                                </telerik:GridTemplateColumn> 
                                <telerik:GridTemplateColumn DataField="BIRIM" HeaderText="Birim" SortExpression="BIRIM" 
                                    HeaderStyle-Width="100px" AllowFiltering="false"
                                    <EditItemTemplate> 
                                        <telerik:RadTextBox ID="txtBirim" runat="server" Text='<%# Bind("BIRIM") %>' Width="100px" 
                                            SelectionOnFocus="CaretToEnd"
                                        </telerik:RadTextBox> 
                                        <asp:RequiredFieldValidator ID="rfvBirim" runat="server" ControlToValidate="txtBirim" 
                                            Display="Dynamic" ErrorMessage="Parametre birimi girilmek zorundadır."></asp:RequiredFieldValidator> 
                                    </EditItemTemplate> 
                                    <ItemTemplate> 
                                        <asp:Label ID="lblBirim" runat="server" Text='<%# Bind("BIRIM") %>'
                                        </asp:Label> 
                                    </ItemTemplate> 
                                </telerik:GridTemplateColumn> 
                                <telerik:GridTemplateColumn DataField="DUYARLILIK" HeaderText="Duyarlılık" SortExpression="DUYARLILIK" 
                                    HeaderStyle-Width="50px" AllowFiltering="false"
                                    <EditItemTemplate> 
                                        <telerik:RadNumericTextBox ID="txtDuyarlilik" runat="server" MinValue="0" MaxValue="4" 
                                            NumberFormat-DecimalDigits="0" ShowSpinButtons="true" Text='<%# Bind("DUYARLILIK") %>' 
                                            Width="50px" SelectionOnFocus="CaretToEnd"
                                        </telerik:RadNumericTextBox> 
                                        <asp:RequiredFieldValidator ID="rfvDuyarlilik" runat="server" ControlToValidate="txtDuyarlilik" 
                                            Display="Dynamic" ErrorMessage="Parametrenin duyarlılığı belirtilmek zorundadır."></asp:RequiredFieldValidator> 
                                    </EditItemTemplate> 
                                    <ItemTemplate> 
                                        <asp:Label ID="lblDuyarlilik" runat="server" Text='<%# Bind("DUYARLILIK") %>'></asp:Label> 
                                    </ItemTemplate> 
                                </telerik:GridTemplateColumn> 
                                <telerik:GridTemplateColumn DataField="ANALIZMETHODU" HeaderText="Analiz Methodu" 
                                    SortExpression="ANALIZMETHODU" HeaderStyle-Width="125px" AllowFiltering="false"
                                    <EditItemTemplate> 
                                        <telerik:RadTextBox ID="txtAnalizMethodu" runat="server" Text='<%# Bind("ANALIZMETHODU") %>' 
                                            TextMode="MultiLine" Rows="4" Width="125px" SelectionOnFocus="CaretToEnd"
                                        </telerik:RadTextBox> 
                                        <asp:RequiredFieldValidator ID="rfvAnalizMethodu" runat="server" ControlToValidate="txtAnalizMethodu" 
                                            Display="Dynamic" ErrorMessage="Parametre analiz methodu belirtilmek zorundadır."></asp:RequiredFieldValidator> 
                                    </EditItemTemplate> 
                                    <ItemTemplate> 
                                        <asp:Label ID="lblAnalizMethodu" runat="server" Text='<%# Bind("ANALIZMETHODU") %>'
                                        </asp:Label> 
                                    </ItemTemplate> 
                                </telerik:GridTemplateColumn> 
                                <telerik:GridButtonColumn ButtonType="ImageButton" ConfirmText="Parametreyi silmek istediğinize emin misiniz?" 
                                    ConfirmTitle="Silme" ConfirmDialogType="RadWindow" UniqueName="DeleteColumn" 
                                    CommandName="Delete" HeaderStyle-Width="20px"
                                </telerik:GridButtonColumn> 
                            </Columns> 
                            <NoRecordsTemplate> 
                                <div style="float: left; width: 100%; text-align: center;"
                                    <strong> 
                                        <asp:Label ID="lblNoData" runat="server" Text="Gösterilecek her hangi bir veri bulunmadı."></asp:Label> 
                                    </strong> 
                                </div> 
                            </NoRecordsTemplate> 
                        </MasterTableView>    
                        <ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true" FileName="ParametreKarti"
                        <Pdf PageTitle="Parametre Karti" PaperSize="A4" Author="DSI" PageWidth="100%" PageLeftMargin="3%" PageRightMargin="3%"/>  </ExportSettings> 
                    </telerik:RadGrid> 
                </telerik:RadAjaxPanel> 

codebehind:

protected void gridResult_DeleteCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) 
        { 
            //System.Diagnostics.Debug.Write(ex.Message);//("Parametre", "Event handled.", MessagePriority.NoPrior, MessageType.Trace, ""); 
 
            try 
            { 
                DTO dto = new DTO(); 
                bool resultFlag = ParametreBusiness.DeleteEntity(Convert.ToInt32((e.Item.FindControl("lblNo"as Label).Text)); 
 
                if (resultFlag) 
                { 
                    //Response.Redirect("~/Pages/Parametre/"); 
                } 
                else 
                { 
                    Session["ErrorPage.ErrorMessage"] = "Parametre sayfasında parametre silinmesi sırasında bir hata oluştu. "
                    Session["ErrorPage.PreviousPage"] = Request.Url.PathAndQuery; 
                    Response.Redirect("~/Pages/ErrorPage/?action=error"); 
                } 
            } 
            catch (Exception ex) 
            { 
                System.Diagnostics.Debug.Write(ex.Message);//("Parametre", ex); 
            } 
        } 
 
        protected void gridResult_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) 
        { 
            //System.Diagnostics.Debug.Write(ex.Message);//("Parametre", "Event handled.", MessagePriority.NoPrior, MessageType.Trace, ""); 
 
            try 
            { 
                DTO dto = new DTO(); 
                dto[ParametreEntityFields.No] = Convert.ToInt32((e.Item.FindControl("lblNo"as Label).Text); 
                dto[ParametreEntityFields.Ad] = (e.Item.FindControl("txtAd"as RadTextBox).Text; 
                dto[ParametreEntityFields.Aciklama] = (e.Item.FindControl("txtAciklama"as RadTextBox).Text; 
                dto[ParametreEntityFields.AnalizMethodu] = (e.Item.FindControl("txtAnalizMethodu"as RadTextBox).Text; 
                dto[ParametreEntityFields.Birim] = (e.Item.FindControl("txtBirim"as RadTextBox).Text; 
                dto[ParametreEntityFields.Duyarlilik] = (e.Item.FindControl("txtDuyarlilik"as RadNumericTextBox).Text; 
                dto[ParametreEntityFields.Grubu] = (e.Item.FindControl("ddlGrubu"as RadComboBox).SelectedValue; 
 
                bool resultFlag = ParametreBusiness.UpdateEntity(dto); 
 
                if (resultFlag) 
                { 
                    //Response.Redirect("~/Pages/Parametre/"); 
                } 
                else 
                { 
                    Session["ErrorPage.ErrorMessage"] = "Parametre sayfasında parametre güncellemesi sırasında bir hata oluştu. "
                    Session["ErrorPage.PreviousPage"] = Request.Url.PathAndQuery; 
                    Response.Redirect("~/Pages/ErrorPage/?action=error"); 
                } 
            } 
            catch (Exception ex) 
            { 
                System.Diagnostics.Debug.Write(ex.Message);//("Parametre", ex); 
            } 
        } 
 
        protected void gridResult_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) 
        { 
            gridResult.DataSource = ParametreBusiness.RetrieveCollection();//a list 
        } 

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 13 Apr 2010, 11:59 AM
Hi Coskun,

Basically, this behavior should not be present. The filter expression should be preserved, and the data should be for the edited item, and not for another one. I suspect this may be caused by a problem in the databinding of the control. To further trace the issue, it will be best if you open a formal support ticket, and send us a small working project, demonstrating your setup, and demonstrating the discrepancy in question.
We will review it locally, and advise you further.

Sincerely yours,
Yavor
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Coskun Ince
Top achievements
Rank 2
Answers by
Yavor
Telerik team
Share this question
or