473,394 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

AJAX + ObjectDataSource Refresh Issue

Tried this over in CSharp.General and didn't get anything, so I
thought I'd try again here. If there's an AJAX specific group I could
ask this in, please let me know...I did look.

I'm trying to code what I think is a fairly typical Master/Detail
scenario with two GridViews, using AJAX. Using the Northwind sample,
I have two ObjectDataSources - one which pulls data from the Orders
table, and one that pulls the related data from [Order Details].
Each
has a GridView, each on its own UpdatePanel.
According to timestamps I put on each update panel and the main page,
everything works as it should. The proper panels get refresh for
each
operation (selecting, paging, sorting on the Master GridView). So
why
am I bothering you if it works?
I coded a two second thread.sleep in the Details GridView's
ObjectDataSource to simulate heavy processing latency. Paging and
sorting the Master GridView work as expected - no sleeping - UNTIL I
select a record to show the detail. Once a record is selected, the
[Order Details] _Selecting method fires with every refresh, whether
or
not a new record is selected.
The [Order Details] update panel does NOT refresh, but for some
reason
it is still calling the _Selecting method for the ObjectDataSource.
I've tried moving the ObjectDataSource inside the details update
panel
with no luck.
It doesn't seem like what I'm doing is very atypical. Am I missing
something obvious? Here's the code for the page in question:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:ObjectDataSource ID="dsOrders" runat="server"
DeleteMethod="Delete" InsertMethod="Insert"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetOrderList"
TypeName="dsOrdersTableAdapters.taOrderList"
UpdateMethod="Update">
<DeleteParameters>
<asp:Parameter Name="Original_OrderID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="CustomerID" Type="String" />
<asp:Parameter Name="EmployeeID" Type="Int32" />
<asp:Parameter Name="OrderDate" Type="DateTime" />
<asp:Parameter Name="RequiredDate" Type="DateTime" />
<asp:Parameter Name="ShippedDate" Type="DateTime" />
<asp:Parameter Name="ShipVia" Type="Int32" />
<asp:Parameter Name="Freight" Type="Decimal" />
<asp:Parameter Name="ShipName" Type="String" />
<asp:Parameter Name="ShipAddress" Type="String" />
<asp:Parameter Name="ShipCity" Type="String" />
<asp:Parameter Name="ShipRegion" Type="String" />
<asp:Parameter Name="ShipPostalCode" Type="String" />
<asp:Parameter Name="ShipCountry" Type="String" />
<asp:Parameter Name="Original_OrderID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="CustomerID" Type="String" />
<asp:Parameter Name="EmployeeID" Type="Int32" />
<asp:Parameter Name="OrderDate" Type="DateTime" />
<asp:Parameter Name="RequiredDate" Type="DateTime" />
<asp:Parameter Name="ShippedDate" Type="DateTime" />
<asp:Parameter Name="ShipVia" Type="Int32" />
<asp:Parameter Name="Freight" Type="Decimal" />
<asp:Parameter Name="ShipName" Type="String" />
<asp:Parameter Name="ShipAddress" Type="String" />
<asp:Parameter Name="ShipCity" Type="String" />
<asp:Parameter Name="ShipRegion" Type="String" />
<asp:Parameter Name="ShipPostalCode" Type="String" />
<asp:Parameter Name="ShipCountry" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
<asp:Label ID="lblPageTime" runat="server" Text="Label"></
asp:Label>
<asp:UpdatePanel ID="UpdatePanel2" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lblMasterTime" runat="server"
Text="Label"></
asp:Label>
<asp:GridView ID="GridView1" runat="server"
AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="OrderID"
DataSourceID="dsOrders">
<Columns>
<asp:BoundField DataField="OrderID" HeaderText="Order
ID" InsertVisible="False" ReadOnly="True"
SortExpression="OrderID">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="CompanyName"
HeaderText="Customer" SortExpression="CompanyName">
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="OrderDate"
DataFormatString="{0:d}" HeaderText="Date Ordered"
HtmlEncode="False" ReadOnly="True"
SortExpression="OrderDate">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="RequiredDate"
DataFormatString="{0:d}" HeaderText="Date Required"
HtmlEncode="False" SortExpression="RequiredDate">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="ShippedDate"
DataFormatString="{0:d}" HeaderText="Date Shipped"
HtmlEncode="False" SortExpression="ShippedDate">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:CommandField SelectText="View Details"
ShowSelectButton="True" />
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:ObjectDataSource ID="dsOrderDetails" runat="server"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetOrderDetailsList"
TypeName="dsOrdersTableAdapters.taOrderDetails"
OnSelecting="dsOrderDetails_Selecting">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1"
Name="OrderID" PropertyName="SelectedValue" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:Label ID="lblChildTime" runat="server" Text="Label"></
asp:Label>
<asp:GridView ID="GridView2" runat="server"
AutoGenerateColumns="False" DataKeyNames="OrderID,ProductID"
DataSourceID="dsOrderDetails">
<Columns>
<asp:BoundField DataField="ProductName"
HeaderText="ProductName" SortExpression="ProductName" />
<asp:BoundField DataField="UnitPrice"
HeaderText="UnitPrice" SortExpression="UnitPrice" />
<asp:BoundField DataField="Quantity"
HeaderText="Quantity" SortExpression="Quantity" />
<asp:BoundField DataField="Discount"
HeaderText="Discount" SortExpression="Discount" />
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="GridView1"
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<br />
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/
Default.aspx">View without AJAX</asp:HyperLink>
</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Default2 : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
lblPageTime.Text = DateTime.Now.ToLongTimeString();
lblMasterTime.Text = DateTime.Now.ToLongTimeString();
lblChildTime.Text = DateTime.Now.ToLongTimeString();
}
protected void dsOrderDetails_Selecting(object sender,
ObjectDataSourceSelectingEventArgs e) {
System.Threading.Thread.Sleep(2000);
}
}

May 2 '07 #1
0 5476

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Nico VanHaaster | last post by:
Hello all, I have run across an issue with IE 6.0+. I have a page that makes an XMLHttpRequest to the webserver to update a report on the page. The first time you hit the refresh report button...
7
by: =?Utf-8?B?Tmlrb2xheSBFdnNlZXY=?= | last post by:
Hi! I know this topic has been discussed a long way, but I haven't found any apparent solution (maybe I shouldn't be looking for a one :)) I have a very simple application with one page and with...
0
by: yisroem | last post by:
Hi Everybody, I am just getting to grips with ASP.NET 2.0. as per my reading I understand that it is possible for a data control (such as the GridView, DetailsView etc.) to reflect upon the...
10
by: Piotr Nowak | last post by:
Hi, Say i have a server process which listens for some changes in database. When a change occurs i want to refresh my page in browser by notyfinig it. I do not want to refresh my page i.e....
10
by: paulie | last post by:
Hi, I have been experiencing an issue when trying to use AJAX to reload a DIV area using a timer of 2000ms, which contains a html page with another DIV and javascript. Scenario -------------...
2
by: malcster2 | last post by:
hello, i am a beginner to ajax. i have created a mysql database, which i would like to access from a web page. i have created 3 files, a html to display the data, a php file to extract the data,...
11
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I have run into a situation that if a page/tab that uses the Ajax toolkit (using .net version 3.5) is closed before the Ajax enable controls complete loading, then IE locks up. Does it in both IE7...
3
by: SAL | last post by:
Hello, I'm using vs2005 and ajax exentions 1.0.61025.0. I have a page with a Gridview control that's inside of an update panel. I also have a DetailsView on this page inside of another update...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.