 |
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
 | This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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
|
|
|
|
|

July 13th, 2010, 10:05 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
DetailsView Data Control behaviour
I am on Chapter 12 page 393 at step 5 of the try it out. After dragging the DetailsView Data Control and following step 1-5 (I have trippled checked all steps) I do not get the same output in the code view of Genres.aspx. What I do get is:
<asp:DetailsViewID="DetailsView1"runat="server"DataSourceID="SqlDataSource1"
DefaultMode="Insert"Height="50px"Width="125px">
<Fields>
<asp:CommandFieldShowInsertButton="True"/>
</Fields>
</asp:DetailsView>
This is very different from the snippet of what I should be seeing (What the book shows and is in the Source folder ), which is:
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="Id" DataSourceID="SqlDataSource1" DefaultMode="Insert" Height="50px" Width="125px">
<Fields>
<asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True" SortExpression="Id" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="SortOrder" HeaderText="SortOrder" SortExpression="SortOrder" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
my issue is when I view Genres.aspx in the browser it shows an input field for the ID which is the primary key field that should not be showing according to the book. Please note I am usinf VS 2010, is this why. Its seems like a very big fundamental diffeence?
TYIA
__________________
Wind is your friend
Matt
|
|

July 18th, 2010, 08:19 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
No, this shouldn't be fundamentally different, other than that VS 2010 has some issues where it sometimes just doesn't add the right information.
But are you sure that the Id column is indeed a primary key and identity in the database?
Imar
|
|

July 18th, 2010, 06:55 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
Hi Imar. Yes 100%. All my tables ID column is an auto incrimenting PK. Look there are clearly differences between the examples and what 2010 gives me. I have seen a few as I progress through the book, just none this fundamentally different. When ever I come accross one I undo the steps in the try it out and re-do them just incase I have takena wrong turn. Thank you for your time....
__________________
Wind is your friend
Matt
|
|

July 19th, 2010, 02:56 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
It shouldn't be like this; it should pick up the columns and create the right fields. Can you show the code for the SqlDataSource (and please use the Remove Text Formatting button on the post editor's toolbar before wrapping the code in Code tags).
Quote:
|
my issue is when I view Genres.aspx in the browser it shows an input field for the ID which is the primary key field that should not be showing according to the book
|
This is a side effect of the incorrect field setup. VWD should detect the column structure and add stuff like InsertVisible to the field automatically. Because it doesn't, you get to see the field in the editor.
I don't think this is really that related to VS 2008 versus VS 2010. Both IDEs should do the same thing here; It seems to be a bug in both VS 2008 and VS 2010 as I've seen behavior like this when using either one of them. What happens when you drag a table from the Database / Server Explorer onto a brand new Web Form and then hook up a DetailsView to the SqlDataSource that got added?
Imar
|
|

July 19th, 2010, 06:53 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
Hi Imar. The SqlDataSource code from my Management/Genres.aspx
Code:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:PlanetWroxConnectionString1 %>"
DeleteCommand="DELETE FROM [Genre] WHERE [Id] = @Id"
InsertCommand="INSERT INTO [Genre] ([Name], [SortOrder]) VALUES (@Name, @SortOrder)"
ProviderName="<%$ ConnectionStrings:PlanetWroxConnectionString1.ProviderName %>"
SelectCommand="SELECT [Id], [Name], [SortOrder] FROM [Genre]"
UpdateCommand="UPDATE [Genre] SET [Name] = @Name, [SortOrder] = @SortOrder WHERE [Id] = @Id">
<DeleteParameters>
<asp:Parameter Name="Id" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="SortOrder" Type="Int32" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="SortOrder" Type="Int32" />
<asp:Parameter Name="Id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
Additionaly - When I carry out the steps on a new webform I get the same result.
__________________
Wind is your friend
Matt
Last edited by mat41; July 19th, 2010 at 07:01 PM..
|
|

July 20th, 2010, 01:24 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
That looks good to me, so this is getting stranger and stranger.
What happens when you click Refresh Schema on the Smart Tasks panel for the DetailsView? Do you then get the correct fields?
If not, I think this is a bug in VWD that you can report at http://connect.microsoft.com
Cheers,
Imar
|
|

November 1st, 2010, 03:18 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
In case anyone else runs into this, here's a post that describes a possible solution to the problem: DetailsView control
Cheers,
Imar
|
|
 |