473,778 Members | 1,913 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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 ObjectDataSourc e, 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 DBConcurrencyEx ception. 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.as px

1 <%@ Page Language="C#" MasterPageFile= "~/MasterPage.mast er" AutoEventWireup ="true" CodeFile="Event Details.aspx.cs " Inherits="Event Details" Title="Untitled Page" %>
2 <asp:Content ID="Content1" ContentPlaceHol derID="ContentP laceHolder1" Runat="Server">
3 <asp:DetailsVie w ID="DetailsView 1" runat="server" Height="50px" Style="position : relative"
4 Width="125px" OnModeChanging= "DetailsView1_M odeChanging" AutoGenerateRow s="False" DataSourceID="O bjectDataSource 1" DataKeyNames="I D,Timestamp">
5 <Fields>
6 <asp:BoundFie ld DataField="Titl e" HeaderText="Tit le" SortExpression= "Title" />
7 <asp:BoundFie ld DataField="Star tDateTime" HeaderText="Sta rtDateTime" SortExpression= "StartDateT ime" />
8 <asp:BoundFie ld DataField="EndD ateTime" HeaderText="End DateTime" SortExpression= "EndDateTim e" />
9 <asp:BoundFie ld DataField="Desc ription" HeaderText="Des cription" SortExpression= "Descriptio n" />
10 <asp:CommandFie ld ShowEditButton= "True" />
11 </Fields>
12
13 </asp:DetailsView >
14 <asp:ObjectData Source ID="ObjectDataS ource1" runat="server" DataObjectTypeN ame="BSC.PID.BO .CalendarEvent"
15 SelectMethod="G etEvent" TypeName="BSC.P ID.BLL.Calendar EventManager" UpdateMethod="S ave">
16 <SelectParamete rs>
17 <asp:QueryStrin gParameter Name="id" QueryStringFiel d="id" Type="Int32" />
18 </SelectParameter s>
19 </asp:ObjectDataS ource>
20 </asp:Content>
21
22



EventDetails.as px.cs



1 using System;
2 using System.Data;
3 using System.Configur ation;
4 using System.Collecti ons;
5 using System.Web;
6 using System.Web.Secu rity;
7 using System.Web.UI;
8 using System.Web.UI.W ebControls;
9 using System.Web.UI.W ebControls.WebP arts;
10 using System.Web.UI.H tmlControls;
11
12 using BSC.PID.BO;
13 using BSC.PID.BLL;
14
15 public partial class EventDetails : System.Web.UI.P age
16 {
17 protected void Page_Load(objec t sender, EventArgs e)
18 {
19
20 }
21 protected void DetailsView1_Mo deChanging(obje ct sender, DetailsViewMode EventArgs e)
22 {
23
24 }
25 }
26
Dec 18 '07 #1
1 4145
ledneh
2 New Member
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
1511
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 determines what training is required. I need to have a form that 'checks' a employee/jobcode table(which contains a jobcodenum field and a employeenum field) to make sure that employee is required to take that course. for example: when I press a cmd...
5
1332
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 class, ClientSidePage, which inherits system.web.ui.page. In my main page (with the fields to be checked) I have used inherits ClientSidePage. When I try to run the main page none of the normal events (like page_load) can be found as if it isn't...
6
2083
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 each page of my project without clicking on the "save" button and he can also close the browser without saving. My customer wants the user to be informed about loss of data. If any page is left without saving data changes then on the same page a...
30
3405
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 commits it. How does the other user get the updated view without polling for changes? Is there some sort of callback mechanism that can be set up on the dataset or connection? TIA
4
2206
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 As Control For Each ctl In Controls If TypeOf ctl Is TextBox Then If ctl.Value <> ctl.OldValue Then Dim ans As Integer ans = MsgBox("A record has changed." & vbcrkf + vbCrLf & _
0
1299
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 data changes (0 inserts, 100 updates, 0 deletes, 0 conflicts)" Then at the very end of the "Action Messages" the following appears: "Merged 31489 data changes (453 inserts, 30893 updates, 143 deletes, 14
0
1053
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 learn about using Data Sources. My requirements are pretty simple, the underlying data in the SQL database is modified from outside sources or triggers I wrote in the DB. For the purpose of this question, all I realy want to do is display in...
0
9465
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10296
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10127
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10068
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8954
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5497
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4031
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2863
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.