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:
codebehind:
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 |
} |