Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 18th, 2007, 07:00 PM
Registered User
 
Join Date: Dec 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default DetailsView: chk 4 changed data before modechange?

Sorry about the shortform subject, there--ran out of room.

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.

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime Error 7878 Data has been Changed ayazhoda Access VBA 0 May 22nd, 2008 09:08 AM
track page data has changed webmahesh XSLT 1 December 12th, 2007 06:54 PM
How to check whether page data has changed webmahesh JSP Basics 0 December 12th, 2007 04:38 AM
Combox not showing data when criteria is changed Mitch Access 2 September 10th, 2004 11:54 AM
Data has changed error with linked ODBC table Wim Leys Access 7 June 8th, 2004 06:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.