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

Radgrid row added on page refresh

3 Answers 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brock
Top achievements
Rank 1
Brock asked on 14 Oct 2011, 09:05 PM
I have a radgrid on my .aspx page.

When I click the plus on the radgrid and insert a new row, the row inserts without any problems. However... if I then refresh the page by pressing F5, another row is added that matches the last. I can keep pressing F5 and it keeps adding that same row with the information I entered.

If I edit a row in the radgrid and then press F5, it won't add a new row... it will simply perform a postback as expected. The same is true if I delete a row. It's as if editing or deleting a row clears something out so that it stops inserting.

Any idea what's going on?

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 15 Oct 2011, 06:11 AM
Hello,

This is the not issue from Radgrid.
Please look for this asp.net forum.

You can also check below link for same.

http://stackoverflow.com/questions/743580/page-refresh-causes-duplicate-post-in-asp-net-applications

refresh page without prompt the resend information + asp.net

Thanks,
Jayesh Goyani
0
Yueming
Top achievements
Rank 1
answered on 01 Jun 2017, 05:52 PM

search something and edit the list record,  the page refreshes and edit is start from record 1 in the radgrid

 

<%@ Page Language="VB" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="PhoneSearch._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Default</title>
<link href="Styles/esp-main.css" rel="stylesheet" />
<style type="text/css">
.auto-style1 {
width: 80%;
}
</style>
</head>
<body style="height: 60%; width: 100%; margin: 0px;">
<form id="form1" runat="server">
<div>
<table style="width: 100%; height: 94px; border-spacing: 0px;">
<tr>
<td style="background-image: url('images/AlbanyCountyPhoneSearch3.png'); background-repeat: no-repeat; width: 358px; height: 94px;"></td>
<td align="center" style="background-image: url('images/AlbanyCountyPhoneSearch4.png'); background-repeat: repeat-x">
<table cellpadding="0" cellspacing="0" class="auto-style1" style="width: 440px">
<%-- <tr>
<td align="right">
<asp:TextBox ID="TextBoxSearch" runat="server" Height="33px" Width="400px"></asp:TextBox></td>
<td align="left" style="width: 40px; height: 40px">
<asp:ImageButton ID="ibSearch" runat="server" ImageUrl="~/images/Find 3.png" />
</td>
</tr>--%>
<tr>
<td align="right">
<telerik:RadSearchBox RenderMode="Lightweight" ID="RadSearchBox1" runat="server" Height="40px" Width="440" DropDownSettings-Height="200px" Skin="Silk"
DataSourceID="SqlDataSource1" EmptyMessage="Search" Filter="StartsWith"
DataTextField="Name" DataValueField="Name" DataContextKeyField="ID">
</telerik:RadSearchBox>
</td>
<td align="left" style="width: 40px; height: 40px"></td>
</tr>
</table>
</td>
<td align="right" style="background-image: url('images/AlbanyCountyPhoneSearch4.png'); background-repeat: repeat-x; width: 100px;">
<asp:HyperLink ID="hlAdministrator" runat="server" Font-Bold="True" Font-Italic="True" ForeColor="Blue" NavigateUrl="~/Administrator.aspx">Administrator</asp:HyperLink>
&nbsp;
&nbsp; </td>
</tr>
</table>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:AlbanyPhoneString %>"
SelectCommand="SELECT ID, Name FROM [tblPhoneList]"></asp:SqlDataSource>
</div>
<div>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
<telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All" EnableRoundedCorners="false" />
<div style="margin: auto; padding-left: 10pt;">

<fieldset id="FiledSet1" style="width: 96%;">
<legend style="border-style: solid; font-family: Arial, Helvetica, sans-serif; font-size: large;">Phone List</legend>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function RowDblClick(sender, eventArgs) {
sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
}
</script>
</telerik:RadCodeBlock>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGridPhoneList">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGridPhoneList" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
</telerik:RadAjaxLoadingPanel>
<telerik:RadGrid ID="RadGridPhoneList" runat="server" AllowPaging="True" PageSize="20" DataSourceID="SqlDataSourcePhoneList" Skin="Outlook"
AllowSorting="True" AutoGenerateColumns="False" ShowStatusBar="True" AllowFilteringByColumn="True" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
AllowAutomaticUpdates="True" EnableViewState="true">
<GroupingSettings CaseSensitive="false" />
<%--use <ClientSettings> to set auto resize radgrid on client screen resolutin--%>
<ClientSettings>
<Resizing AllowColumnResize="true" />
</ClientSettings>
<MasterTableView Width="100%" CommandItemDisplay="Top" DataKeyNames="ID" DataSourceID="SqlDataSourcePhoneList" CommandItemSettings-AddNewRecordText="Add new record" AutoGenerateColumns="False">
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" HeaderText="Edit" HeaderStyle-Width="30px" EditImageUrl="images/edit.png" HeaderStyle-HorizontalAlign="Left">
<ItemStyle CssClass="MyImageButton" HorizontalAlign="Left" />
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn UniqueName="ID" HeaderText="ID" AllowFiltering="false" Visible="false"
DataField="ID" DataType="System.Int32"
FilterControlAltText="Filter ID column" ReadOnly="True" HeaderStyle-Width="1%"
AllowSorting="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Phone" HeaderText="Phone" DataField="Phone" HeaderStyle-Width="80px" FilterControlWidth="70px" HeaderStyle-HorizontalAlign="Center">
<ColumnValidationSettings EnableModelErrorMessageValidation="true" EnableRequiredFieldValidation="true">
<RequiredFieldValidator ErrorMessage="* required" ForeColor="Red"></RequiredFieldValidator>
<ModelErrorMessage BackColor="Red" />
</ColumnValidationSettings>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Department" HeaderText="Department" DataField="Department" HeaderStyle-Width="100px" FilterControlWidth="90px" HeaderStyle-HorizontalAlign="Center" AllowFiltering="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Name" UniqueName="Name" DataField="Name" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="100px" FilterControlWidth="90px" AllowFiltering="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Fax" HeaderText="Fax" DataField="Fax" HeaderStyle-Width="80px" FilterControlWidth="70px" HeaderStyle-HorizontalAlign="Center" AllowFiltering="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Division" HeaderText="Division" DataField="Division" HeaderStyle-Width="80px" FilterControlWidth="70px" HeaderStyle-HorizontalAlign="Center" AllowFiltering="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Floor" UniqueName="Floor" DataField="Floor" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="80px" FilterControlWidth="70px" AllowFiltering="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Building" UniqueName="Building" DataField="Building" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="100px" FilterControlWidth="80px" AllowFiltering="false">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Photo" UniqueName="TemplateColumnPhoto" SortExpression="Photo" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="70" HeaderStyle-Width="70px" AllowFiltering="false" ReadOnly="true">
<EditItemTemplate>
<asp:TextBox ID="TextBoxPhoto" runat="server" Text='<%# Bind("Photo")%>' Width="70" Height="100"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LabelPhoto" runat="server" Text='<%# Eval("Photo")%>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Image Index" UniqueName="TemplateColumnImageIndex" SortExpression="ImageIndex" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="90px" AllowFiltering="false">
<EditItemTemplate>
<asp:TextBox ID="TextBoxImageIndex" runat="server" Text='<%# Bind("ImageIndex")%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="LabelImageIndex" runat="server" Text='<%# Eval("ImageIndex")%>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<%--<telerik:GridBoundColumn HeaderText="Photo" UniqueName="Photo" DataField="Photo" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="70px" AllowFiltering="false" ReadOnly="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Index" UniqueName="ImageIndex" DataField="ImageIndex" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="60px" AllowFiltering="false">
</telerik:GridBoundColumn>--%>
<telerik:GridCheckBoxColumn DataField="Hide" DataType="System.Boolean" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="50" AllowFiltering="false"
FilterControlAltText="Filter Hide column" HeaderText="Hide"
UniqueName="Hide" EditFormColumnIndex="1">
</telerik:GridCheckBoxColumn>
<telerik:GridButtonColumn ConfirmText="Are you sure you want to delete this record?" ButtonType="ImageButton" ImageUrl="~/images/delete.jpg"
CommandName="Delete" Text="Delete this record?" UniqueName="DeleteColumn" HeaderText="X" HeaderStyle-HorizontalAlign="Center">
<HeaderStyle Width="30px" />
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
</telerik:GridButtonColumn>
</Columns>
<SortExpressions>
<telerik:GridSortExpression FieldName="ID" SortOrder="Ascending" />
</SortExpressions>
<EditFormSettings CaptionDataField="ID" CaptionFormatString="Edit Phone List ID = {0}" ColumnNumber="2" EditColumn-ButtonType="PushButton" FormCaptionStyle-ForeColor="#990000" InsertCaption="Add New Record">
<FormTableStyle CellPadding="2" CellSpacing="0" CssClass="module" GridLines="None" Height="90px" Width="100%" />
<EditColumn CancelText="Cancel" UniqueName="EditCommandColumn1" UpdateText="Update">
</EditColumn>
<FormTableButtonRowStyle CssClass="EditFormButtonRow" HorizontalAlign="Left" />
</EditFormSettings>
</MasterTableView>
<ClientSettings>
<ClientEvents OnRowDblClick="RowDblClick"></ClientEvents>
</ClientSettings>
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSourcePhoneList" runat="server"
ConnectionString="<%$ ConnectionStrings:AlbanyPhoneString %>"
InsertCommand="INSERT INTO [tblPhoneList] ([Phone],[Department],[Name],[Fax],[Division],[Floor],[Building],[Photo],[ImageIndex], [Hide]) VALUES (@Phone,@Department,@Name,@Fax,@Division,@Floor,@Building,@Photo,@ImageIndex, @Hide)"
SelectCommand="SELECT Phone, Department, Name, Fax, Division, Floor, Building, '<img src=' + CHAR(39) + 'http://alconet/dataimage/' + LTRIM(ImageIndex) + CHAR(39) + ' alt=' + CHAR(39) + CHAR(39) + ' width=' + CHAR(39) + '70' + CHAR(39) + ' height=' + CHAR(39) + '100' + CHAR(39) + '/>' AS photo, ImageIndex, Hide, ID FROM [tblPhoneList] "
DeleteCommand="DELETE FROM [tblPhoneList] WHERE ID =@ID"
UpdateCommand="UPDATE [tblPhoneList] SET [Phone]= @Phone,[Department] = @Department,[Name]= @Name,[Fax]= @Fax,[Division]= @Division,[Floor]= @Floor,[Building]= @Building,[Photo]=@Photo,[ImageIndex]= @ImageIndex, [Hide]= @Hide WHERE [ID] = @ID">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Phone" Type="String" />
<asp:Parameter Name="Department" Type="String" />
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Fax" Type="String" />
<asp:Parameter Name="Division" Type="String" />
<asp:Parameter Name="Floor" Type="String" />
<asp:Parameter Name="Building" Type="String" />
<asp:Parameter Name="Photo" Type="String" />
<asp:Parameter Name="ImageIndex" Type="String" />
<asp:Parameter Name="Hide" Type="Boolean" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="Phone" Type="String" />
<asp:Parameter Name="Department" Type="String" />
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Fax" Type="String" />
<asp:Parameter Name="Division" Type="String" />
<asp:Parameter Name="Floor" Type="String" />
<asp:Parameter Name="Building" Type="String" />
<asp:Parameter Name="Photo" Type="String" />
<asp:Parameter Name="ImageIndex" Type="String" />
<asp:Parameter Name="Hide" Type="Boolean" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
</fieldset>
</div>
<div>
<p id="back-top">
<a href="#top"><span></span>Top</a>
</p>
</div>
</div>
<div style="background-color: #9DA4B0; color: #FEFDC9; font-size: small; line-height: 30px; vertical-align: middle; text-align: center;">
Copyright &copy; 2017 Albany County Division of Information Services. All Rights Reserved.
</div>
</form>
</body>
</html>

 

Private Sub RadSearchBox1_Search(sender As Object, e As SearchBoxEventArgs) Handles RadSearchBox1.Search
Dim mySearchItem As String = Trim(RadSearchBox1.Text)
'SqlDataSourcePhoneList.SelectCommand = "SELECT Phone, Department, Name, Fax, Division, Floor, Building, '<img src=' + CHAR(39) + 'http://alconet/dataimage/' + LTRIM(ImageIndex) + CHAR(39) + ' alt=' + CHAR(39) + CHAR(39) + ' width=' + CHAR(39) + '70' + CHAR(39) + ' height=' + CHAR(39) + '100' + CHAR(39) + '/>' AS photo, ImageIndex, Hide, ID FROM [tblPhoneList] WHERE (Name LIKE '%" & mySearchItem & "%') OR (Phone LIKE '%" & mySearchItem & "%') "
SqlDataSourcePhoneList.SelectCommand = "SELECT Phone, Department, Name, Fax, Division, Floor, Building, '<img src=' + CHAR(39) + 'http://alconet/dataimage/' + LTRIM(ImageIndex) + CHAR(39) + ' alt=' + CHAR(39) + CHAR(39) + ' width=' + CHAR(39) + '70' + CHAR(39) + ' height=' + CHAR(39) + '100' + CHAR(39) + '/>' AS photo, ImageIndex, Hide, ID FROM [tblPhoneList] WHERE (Name LIKE '%" & mySearchItem & "%') OR (Phone LIKE '%" & mySearchItem & "%') OR (Department LIKE '%" & mySearchItem & "%') OR (Fax LIKE '%" & mySearchItem & "%') OR (Division LIKE '%" & mySearchItem & "%') OR (Floor LIKE '%" & mySearchItem & "%') OR (Building LIKE '%" & mySearchItem & "%') "
RadGridPhoneList.Rebind()
End Sub

0
Eyup
Telerik team
answered on 06 Jun 2017, 06:10 AM
Hi Yueming,

AJAX may sometimes hide both server and client-side errors. Therefore, when developing your app, we highly recommend you to ensure that the functionality works without adding AJAX. Please temporarily disable any AJAX on the page if present (RadAjaxManager, RadAjaxPanel, UpdatePanel, RadXmlHttpPanel, etc.) and enable your script debugger (FireBug or F12) to see whether there are any script or server errors interfering, and make sure that the application works without AJAX. 

If the issue remains, please create a very basic runnable web site demonstrating the problematic behavior and open a formal support thread to send it back to us for further investigation.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Brock
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Yueming
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or