Hello Friends,
I have trouble on my project, and at moment I didn't get to solve it !! I have a grid and when I delete row for first time it is ok, the problem is if I delete the other line in sequence. For some reason, I can not delete any row where the ID is larger than the ID of the deleted first.
I am using telerik ajax Q3 2010 and my project is in C# Framework 4.0 !!
Could you help me with this case ??
See attached my code:
I have trouble on my project, and at moment I didn't get to solve it !! I have a grid and when I delete row for first time it is ok, the problem is if I delete the other line in sequence. For some reason, I can not delete any row where the ID is larger than the ID of the deleted first.
I am using telerik ajax Q3 2010 and my project is in C# Framework 4.0 !!
Could you help me with this case ??
See attached my code:
<div id="divListagem"> <telerik:RadAjaxPanel ID="apListagem" runat="server" LoadingPanelID="lpListagem" Width="100%" HorizontalAlign="NotSet" meta:resourcekey="apListagemResource1"> <telerik:RadGrid ID="dgListagem" runat="server" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" GridLines="None" Skin="Windows7" EnableLinqExpressions="False" OnItemCommand="dgListagem_ItemCommand" OnItemDataBound="dgListagem_ItemDataBound" OnNeedDataSource="dgListagem_NeedDataSource" CellPadding="0" Height="100%" HorizontalAlign="Center" PageSize="20" meta:resourcekey="dgListagemResource" > <SortingSettings SortedAscToolTip="Ordem Crescente" SortedDescToolTip="Ordem Decrescente" SortToolTip="Clique aqui para ordenar" /> <GroupingSettings CaseSensitive="false" /> <ClientSettings> <Scrolling UseStaticHeaders="True" /> </ClientSettings> <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" DataKeyNames="ID" ClientDataKeyNames="ID" CellPadding="0" CellSpacing="0"> <Columns> <telerik:GridTemplateColumn AutoPostBackOnFilter="True" DataField="ID" FilterControlWidth="60px" GroupByExpression="ID Group By ID" HeaderText="Código" meta:resourcekey="gtCodigoResource" ShowFilterIcon="false" SortExpression="ID" UniqueName="ID"> <ItemTemplate> <asp:Literal ID="ltrId" runat="server"></asp:Literal> </ItemTemplate> <HeaderStyle HorizontalAlign="Center" Width="80px" /> <ItemStyle HorizontalAlign="Center" Width="80px" /> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn FilterControlWidth="180px" AutoPostBackOnFilter="True" DataField="Titulo" GroupByExpression="Titulo Group By Titulo" HeaderText="Titulo" meta:resourcekey="gtTituloResource" ShowFilterIcon="False" SortExpression="Titulo" UniqueName="Titulo"> <ItemTemplate> <asp:Literal ID="ltrTitulo" runat="server"></asp:Literal> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn AutoPostBackOnFilter="True" DataField="Idioma" FilterControlWidth="180px" GroupByExpression="Idioma Group By Idioma" HeaderText="Idioma" meta:resourcekey="gtIdiomaResource" ShowFilterIcon="False" SortExpression="Idioma" UniqueName="Idioma"> <ItemTemplate> <asp:Literal ID="ltrIdioma" runat="server"></asp:Literal> </ItemTemplate> <HeaderStyle HorizontalAlign="Center" Width="200px" /> <ItemStyle HorizontalAlign="Center" Width="200px" /> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn AllowFiltering="False" UniqueName="TemplateColumn"> <ItemTemplate> <asp:HyperLink ID="hplEdit" runat="server" meta:resourcekey="hplEditResource" ImageUrl="/CMS/Estrutura/Image/lista_edit.png"></asp:HyperLink> </ItemTemplate> <HeaderStyle HorizontalAlign="Center" Width="19px" /> <ItemStyle HorizontalAlign="Center" Width="19px" /> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn AllowFiltering="False" UniqueName="TemplateColumn1"> <ItemTemplate> <asp:ImageButton ID="ibtExcluir" runat="server" CommandName="Excluir" ImageUrl="/CMS/Estrutura/image/lista_delete.png" meta:resourcekey="ibtExcluirResource" /> </ItemTemplate> <HeaderStyle HorizontalAlign="Center" Width="20px" /> <ItemStyle HorizontalAlign="Center" Width="20px" /> </telerik:GridTemplateColumn> </Columns> <CommandItemTemplate> <div class="CabecalhoBotaoGrid"> <table width="100%"> <tr> <td align="center"> </td> </tr> </table> </div> </CommandItemTemplate> </MasterTableView> <HeaderContextMenu EnableImageSprites="True" CssClass="GridContextMenu GridContextMenu_Default"> </HeaderContextMenu> </telerik:RadGrid> </telerik:RadAjaxPanel> <telerik:RadAjaxLoadingPanel ID="lpListagem" runat="server" Skin="Windows7" meta:resourcekey="lpListagemResource1"> <div id="loading"> <asp:Literal ID="ltrLoading" runat="server" meta:resourcekey="ltrLoadingResource1"></asp:Literal> </div> </telerik:RadAjaxLoadingPanel> </div>protected void dgListagem_ItemCommand(object sender, GridCommandEventArgs e) { try { if (e.CommandName == "Excluir") { GridEditableItem editeditem = (GridEditableItem)e.Item; int codigo = Convert.ToInt32(editeditem.OwnerTableView.DataKeyValues[editeditem.ItemIndex]["ID"].ToString()); try { BLFaq.Delete(codigo); dgListagem.Rebind(); } catch { RadScriptManager.RegisterStartupScript(this.Page, this.GetType(), "showError", string.Format("javascript:alert('{0}')", txtErrorParent.Value), true); } } } catch (Exception ex) { BAL.BLError.TrataErro(new Model.MLError() { Ex = ex, Page = this.Page }); } } protected void dgListagem_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { try { dgListagem.DataSource = BLFaq.SelectListagem(); } catch (Exception ex) { BAL.BLError.TrataErro(new Model.MLError() { Ex = ex, Page = this.Page }); } } protected void dgListagem_ItemDataBound(object sender, GridItemEventArgs e) { var obj = e.Item.DataItem as MLFaq; if (obj == null) return; if (!(e.Item is GridDataItem)) return; GridDataItem item = (GridDataItem)e.Item; Literal control; //Id Literal ltrId = item.FindControl("ltrId") as Literal; ltrId.Text = obj.Id.ToString(); //Titulo Literal ltrTitulo = item.FindControl("ltrTitulo") as Literal; ltrTitulo.Text = obj.Titulo; ////Texto //control = item.FindControl("ltrTexto") as Literal; //control.Text = obj.Texto; //Idioma Literal ltrIdioma = item.FindControl("ltrIdioma") as Literal; ltrIdioma.Text = obj.Idioma; //Editar var edit = item.FindControl("hplEdit") as HyperLink; var qs = new SecureQueryString(); qs["IdItem"] = obj.Id.ToString(); qs["indice"] = param.Index; qs["Update"] = Update.ToString(); qs["Publish"] = Publish.ToString(); qs["ItemMenuId"] = param.ItemMenuId.ToString(); qs["MenuId"] = param.MenuId.ToString(); qs["MenuName"] = param.MenuName; if (!Update) { edit.ImageUrl = "~/CMS/Imagens/pesquisar.png"; edit.ToolTip = "Visualizar Cadastro"; } else { edit.ToolTip = "Editar Cadastro"; } edit.NavigateUrl = string.Format("Cadastro.aspx?IdItem={0}", qs); //Excluir var delete = item.FindControl("ibtExcluir") as ImageButton; if (!Delete) { delete.Enabled = false; delete.ImageUrl = "~/CMS/Estrutura/Image/lista_delete_off.png"; delete.ToolTip = "Sem permissão para Excluir"; } else { delete.ToolTip = "Excluir Registro" ; delete.OnClientClick = string.Format("javascript:return confirm('{0}');", txtMessage.Value); } } }}