473,287 Members | 1,418 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,287 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 5471

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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.