Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 11th, 2012, 04:52 AM
Registered User
Points: 20, Level: 1
Points: 20, Level: 1 Points: 20, Level: 1 Points: 20, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 13 - DetailsView Issue

I have replayed this try out twice and have a couple of issues.

1. If I open the Smart Tasks Panel on the DetailsView Control, there is no facility to Enable Inserting.
2. If I look through the DetailsView object's properties I cannot find a facility to Enable Inserting

So what this means is I have to add this expression to the Markup:

Code:
 <asp:CommandField ShowInsertButton="True>
Am I missing something here?
Reply With Quote
  #2 (permalink)  
Old April 11th, 2012, 05:19 AM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

This usually means that you haven't made the Id column a primary key. The controls need a primary key in order to enable Insert behavior. To fix it:

1. Open the database, locate your table, click the Id column and then click the lock icon on the toolbar to make it a primary key. Also check that you made this an Identity column.
2. Redo the steps that generate the SQL statements.

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!
Reply With Quote
  #3 (permalink)  
Old April 11th, 2012, 05:34 AM
Registered User
Points: 20, Level: 1
Points: 20, Level: 1 Points: 20, Level: 1 Points: 20, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default The Primary Key is Defined

Imar
Thanks for the suggestion. The primary key for both tables is set to the ID column. Both fields are int and Identity columns.

There is another related problem which is the DataGrid will not allow an Insert.

Is there another reason for this behaviour? Perhaps the way SQL Server Express is configured?

I thought I would try to generate the SQL to create the table to prove it had a primary key and was an Identity column.

So I tried to access the PlanetWrox database using SSMS from a Developer version of SQL Server 2008. The PlanetWrox database did not show under the SQLExpress Server, so I attempted to make an attachment to PlanetWrox.mdf. This resulted in this error:

TITLE: Microsoft SQL Server Management Studio
------------------------------

Attach database failed for Server 'PGDT\SQLEXPRESS'. (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdN...r&LinkId=20476

------------------------------
ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

------------------------------

Unable to open the physical file "C:\BegASPNET\DatabaseTest\App_Data\PlanetWrox.mdf ". Operating system error 5: "5(failed to retrieve text for this error. Reason: 15105)". (Microsoft SQL Server, Error: 5120)

For help, click: http://go.microsoft.com/fwlink?ProdN...0&LinkId=20476

------------------------------
BUTTONS:

OK
------------------------------

Last edited by pgrant; April 11th, 2012 at 06:16 AM..
Reply With Quote
  #4 (permalink)  
Old April 11th, 2012, 05:49 AM
Imar's Avatar
Wrox Author
Points: 72,022, Level: 100
Points: 72,022, Level: 100 Points: 72,022, Level: 100 Points: 72,022, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,076
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Maybe the SqlDataSource doesn't support inserting? To check, open its Smart Tasks panel and choose Configure DataSource. Then click Next and then Advanced. Make sure the option for Generate INSERT, UPDATE and DELETE statements is checked.

If that doesn't help can you a) describe which page / TIO exercise you're working on and b) post the full code for the page you're working on?

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!
Reply With Quote
  #5 (permalink)  
Old April 11th, 2012, 06:51 AM
Registered User
Points: 20, Level: 1
Points: 20, Level: 1 Points: 20, Level: 1 Points: 20, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default That Fixed It

Imar
Thanks - that fixed it.

I went back to the previous exercise to try to find out why this happened. I have tried to recreate the DataGrid via drag and drop onto the design surface and in markup. Doing it either way resulted in the Generate Insert, Update and Delete being correctly selected.

I think I must have somehow gone sausage fingered on the previous exercise.

Many thanks.

PG
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LINQ Chapter 13 DataBind issue mat41 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 July 18th, 2010 06:45 PM
Chpt 13 - issue with DNN controls not appearing in VS2008 Meister1867 BOOK: Professional DotNetNuke 5: Open Source Web Application for ASP.NET ISBN: 978-0-470-43870-1 0 August 29th, 2009 09:31 PM
Chapter 13-index.php issue Swilling BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 February 25th, 2009 12:15 AM
DetailsView Issue. midway11 ASP.NET 1.x and 2.0 Application Design 5 December 4th, 2006 11:51 AM
Gridview & DetailsView Database Image Issue ayadrocks ASP.NET 2.0 Basics 1 December 27th, 2005 05:50 PM



All times are GMT -4. The time now is 03:05 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.