473,406 Members | 2,954 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,406 software developers and data experts.

C#-WEB: DetailsView, ModeChanging, and checking for data changes

2
I've been working on concurrency checking for an application I'm building, and a minor part of it has me slightly stumped.


I've got a DetailsView that populates from an ObjectDataSource, using business objects with optimistic concurrency checking built in in my Save() method (against a timestamp column). This can be proven to work perfectly in the following scenario:

- Start app, go to the DetailsView page (defaults to readonly), open a new window

- In one window, go to Update mode

- In the other window, go to Update mode, make a change, click Update

- In the first window, make a change and click update

This will cause my code to generate a DBConcurrencyException. All well and good. However, take the following scenario:

- Start app, go to DetailsView page, open a new window

- In one window, go to update mode, make a change, click update

- In the other window, go to Update mode

You will ender Update mode with the changed data. Now, technically, this works, however when this happens (data changed between the time it was opened for reading and the time it was opened for writing) I want to alert the user.

My first thought is to add something to the ModeChanged event for the DetailsView, but what to add to do the checking I am unsure about. Does anyone have any advice here?

Thanks!



Here's the relevant code.


EventDetails.aspx

1 <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="EventDetails.aspx.cs" Inherits="EventDetails" Title="Untitled Page" %>
2 <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
3 <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Style="position: relative"
4 Width="125px" OnModeChanging="DetailsView1_ModeChanging" AutoGenerateRows="False" DataSourceID="ObjectDataSource1" DataKeyNames="ID,Timestamp">
5 <Fields>
6 <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
7 <asp:BoundField DataField="StartDateTime" HeaderText="StartDateTime" SortExpression="StartDateTime" />
8 <asp:BoundField DataField="EndDateTime" HeaderText="EndDateTime" SortExpression="EndDateTime" />
9 <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
10 <asp:CommandField ShowEditButton="True" />
11 </Fields>
12
13 </asp:DetailsView>
14 <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DataObjectTypeName="BSC.PID.BO.CalendarEvent"
15 SelectMethod="GetEvent" TypeName="BSC.PID.BLL.CalendarEventManager" UpdateMethod="Save">
16 <SelectParameters>
17 <asp:QueryStringParameter Name="id" QueryStringField="id" Type="Int32" />
18 </SelectParameters>
19 </asp:ObjectDataSource>
20 </asp:Content>
21
22



EventDetails.aspx.cs



1 using System;
2 using System.Data;
3 using System.Configuration;
4 using System.Collections;
5 using System.Web;
6 using System.Web.Security;
7 using System.Web.UI;
8 using System.Web.UI.WebControls;
9 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11
12 using BSC.PID.BO;
13 using BSC.PID.BLL;
14
15 public partial class EventDetails : System.Web.UI.Page
16 {
17 protected void Page_Load(object sender, EventArgs e)
18 {
19
20 }
21 protected void DetailsView1_ModeChanging(object sender, DetailsViewModeEventArgs e)
22 {
23
24 }
25 }
26
Dec 18 '07 #1
1 4123
ledneh
2
Bump for the new day. Anyone?
Dec 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Chuckles | last post by:
Ok I am attempting to build a training database that records the employees training required vs. training received. My problem lies in the fact that the jobcode(s) assigned to that employee ...
5
by: D James | last post by:
Scott Mitchell published an article (on the 4GuysFromRolla site) on checking whether data has changed on a page before allowing a user to leave the page. I have used his solution and created a...
6
by: Frank Esser | last post by:
Hallo, I've got a project with about 10 pages. On each of them the user can do data changes (mostly datagrid interactions; the datagrids are bound to datasets). The user is able to jump to...
30
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and...
4
by: gazelle04 | last post by:
I'm trying to track data changes on my database. On form I create a procedure on Before Update event to track data changes, here it is: (It also puts the username who changes the record. Dim ctl...
0
by: Benzine | last post by:
I recently rolled out replication on our production server (MS SQL 2000 SP4) and every time a subscriber tries to sync the following always appears in the Merge Agent History: "Downloaded 100...
0
by: Edwin Elston | last post by:
I'm new with Data Sources and am using VB.Net in VS2005, although I have VS2010 available if it matters. In previous code I just wrote queries using OleDbConnections and OleDbCommands but wanted to...
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.