Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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
 
Old January 19th, 2014, 06:25 PM
Authorized User
 
Join Date: Jan 2014
Posts: 10
Thanks: 2
Thanked 0 Times in 0 Posts
Default Visual Studio 2010 Professional & DetailsView control

Hello,

I just wanted to check and see if it's something I did wrong, but I followed the instructions for dragging & dropping the DetailsView control into the Genres.aspx page as specified in the Try It Out exercise on Chapter 13, page 443.

The GridView control worked just fine, dragging & dropping it set everything up perfectly. However, when I tried to add the DetailsView control afterwards, it wasn't quite so neat.

Here's what I did, exactly:

1.) Dragged a DetailsView control onto the SqlDataSource control in design view. It added it between the GridView and SqlDataSource controls just fine.

2.) Opened the DetailsView Smart Tasks Panel and chose the same data source used by the GridView control (SqlDataSource1)

3.) Checked off "Enable Inserting" in the Smart Tasks Panel

4.) Pressed F4 on my keyboard to go to the Properties Grid, located the DefaultMode property and set it to Insert.

I then went into Markup View as you instructed, and noticed that the generated code for the DetailsView was missing quite a bit. It never inserted AutoGenerateRows="False" or DataKeyNames="Id" into the asp:DetailsView control.

Also, under <Fields>....</Fields> the only entry I saw was <asp:CommandField ShowInsertButton="True">

All three of the asp:BoundField were not generated. I had to type them in manually. Once I added those things it worked as presented in the book.

Maybe my version of Visual Studio doesn't recognize the right things to do when setting the data source because it's not configured properly... Or maybe I left a step out? I am not sure.

Thanks in advance for your help.
 
Old January 19th, 2014, 06:31 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

This may be a bug in Visual Studio. Another reader ran into this some time ago as well.

Here's what I have added in my upcoming Beginning ASP.NET 4.5.1. book to work around the issue:

Quote:
If you don’t see the three BoundField elements, open the Smart Task panel for the DetailsView, click Refresh schema, click No when asked to refresh the fields and keys for the GridView, but click Yes when asked the same question for the DetailsView. This leaves the GridView unmodified and then correctly adds the fields for the DetailsView.
Hope this helps,

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:
techiegeekster40 (January 19th, 2014)
 
Old January 19th, 2014, 06:49 PM
Authorized User
 
Join Date: Jan 2014
Posts: 10
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Thanks Imar!

That worked like a charm. Guess it is a bug in VS 2010 Pro. :)
 
Old January 20th, 2014, 07:40 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

It still is an issue in VS 2013. For some reason, VS loses the meta data about the table making it impossible to set up the correct control properties and fields.

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!
 
Old January 20th, 2014, 09:59 PM
Authorized User
 
Join Date: Jan 2014
Posts: 10
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Hmm, interesting. Thank you for the update. :)

Oh here's one for you to ponder. Say I was building a hypothetical form in which an end user is setting up a reservation for themselves, as well as N other people. I would first ask them how many additional people besides themselves would be attending.

The form would then duplicate the input fields - nothing complex, just first name, last name and age of each person, N+1 times (to accommodate the original customer and the extra N attendees)

How would I go about setting this up in a single submission that would loop through each set of first name / last name / age (N+1 times) and insert them one at a time into the database?

Thanks in advance!
 
Old January 21st, 2014, 05:25 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

This Google search may come in handy: https://www.google.com/#q=asp+net+cr...ls+dynamically

It's a bit out of the scope of the book to discuss here, but hopefully the first couple of links will show you how to accomplish that.

Cheers,

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!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Studio 2010 vbboyd ASP.NET 4 General Discussion 0 January 26th, 2012 06:41 PM
Can Visual Studio 2010 Professional create a Windows XP executable? CoderTim .NET 4 and Visual Studio 2010 General Discussions 0 October 13th, 2010 03:29 PM
Visual Studio 2010 jack_hilary BOOK: Beginning ASP.NET 4 : in C# and VB 4 April 28th, 2010 09:06 AM
Visual Studio 2010 in Focus at Great Indian Developer Summit 2010 shaguf5575 ASP.NET 1.x and 2.0 Application Design 0 February 24th, 2010 07:03 AM
Visual Studio 2010 in Focus at Great Indian Developer Summit 2010 shaguf5575 ASP.NET 1.x and 2.0 Application Design 0 February 24th, 2010 07:02 AM





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