Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion 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
  #21 (permalink)  
Old October 8th, 2014, 11:10 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Isn't this the same issue as before? The column you are trying to update is not part of your INSERT or UPDATE statement...

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
markhh (October 24th, 2014)
  #22 (permalink)  
Old October 8th, 2014, 03:58 PM
Authorized User
Points: 303, Level: 6
Points: 303, Level: 6 Points: 303, Level: 6 Points: 303, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: , , United Kingdom.
Posts: 71
Thanks: 23
Thanked 0 Times in 0 Posts
Default

Hi Imar, yes I agree with your post. It looks like I am misunderstanding what the events are capable of or how they work. I thought after reading pages 469 to 472 that the method below by itself was capable of updating the 'Your_Age' column. Can you enlighten me,

Regards
Mark

Code:
 protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e)
    {
        e.Values["Your_Age"] = 22;
    }
  #23 (permalink)  
Old October 8th, 2014, 04:39 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

The DetailsView and associated SqlDataSource control can get data from the database, but also send updates back. For the updates, you can use INSERT, UPDATE and DELETE commands.

All the SqlDataSource knows about the table is what you specify in the respective commands. This means it cannot update columns you don't specify in the SQL command.

In order to build up the values for the command, the control looks at the various *Parameters you specify in the code. Each parameter maps to a placeholder in the SQL statement. When you build your query using the query designer, VS generates the appropriate placeholders and parameters for you.

When the data is sent to the database, the DetailsView provides the data the user entered in the various web controls. The SqlDataSource then uses that data to build up the SQL statement. Using the various events you can *change* the value of the various parameters. E.g. this:

e.Values["Your_Age"] = 22;

overrides whatever the Your_Age parameter had as a value *provided you specified it as a parameter in the SqlDataSource control*.

Does this help?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
markhh (October 24th, 2014)
  #24 (permalink)  
Old October 24th, 2014, 02:04 PM
Authorized User
Points: 303, Level: 6
Points: 303, Level: 6 Points: 303, Level: 6 Points: 303, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: , , United Kingdom.
Posts: 71
Thanks: 23
Thanked 0 Times in 0 Posts
Thumbs up

Hi Imar, yes very helpful and many thanks for all your replies with this one,

Best Wishes
Mark




Similar Threads
Thread Thread Starter Forum Replies Last Post
Images and Graphics Not Appearing jh3144 BOOK: PHP and MySQL 24-Hour Trainer 0 August 17th, 2012 03:01 PM
instead of font boxes appearing macdev BOOK: Beginning Mac OS X Programming 1 August 22nd, 2007 05:27 AM
Database not appearing in browser sevans BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 May 30th, 2007 06:46 AM
form re-appearing problem Derek_05 Access VBA 1 January 16th, 2006 07:50 PM
Javascript Errors Not Appearing itHighway Javascript How-To 1 October 13th, 2005 01:30 AM





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