Wrox Programmer Forums
|
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
 
Old March 6th, 2011, 05:35 PM
Authorized User
 
Join Date: Mar 2011
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
Default web error running chap 12 Customizing GridView Columns

When I press Ctrl+f5 on step 12 p.407 for the Customizing GridView Columns, the Reviews.aspx web page opens fine. I choose a genre from the dropdownlist - when I do the following web error message shows in a message box titled "Webpage error":

Line: 5
Error: Sys.WebForms.PageRequestManagerServerErrorExceptio n: Could not determine a MetaTable. A MetaTable could not be determined for the data source 'SqlDataSource2' and one could not be inferred from the request URL. Make sure that the table is mapped to the dats source, or that the data source is configured with a valid context type and table name, or that the request is part of a registered DynamicDataRoute.

I redid the entire chapter and copied the PlanetWrox database (.mdf & .ldf) from the source code to the app_data folder and still get the same message.

Help! Any ideas?
 
Old March 6th, 2011, 05:51 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,

Sounds like you used incorrect column types. Can you post your code? Makes it a lot easier to see what's going 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!
 
Old March 6th, 2011, 08:29 PM
Authorized User
 
Join Date: Mar 2011
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
Default Code

<%@ Page Title="Planet Wrox - Management - Reviews" Language="VB" MasterPageFile="~/MasterPages/ManagementMaster.master" AutoEventWireup="false" CodeFile="Reviews.aspx.vb" Inherits="Management_Reviews" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True"
AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="Name"
DataValueField="Id">
<asp:ListItem Value="" Selected="True">Please select a genre</asp:ListItem>
</asp:DropDownList>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="Id" DataSourceID="SqlDataSource2">
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="Id"
DataNavigateUrlFormatString="AddEditReview.aspx?Id ={0}" DataTextField="Title"
HeaderText="Title" />
<asp:TemplateField ConvertEmptyStringToNull="False" HeaderText="Authorized"
SortExpression="Authorized">
<EditItemTemplate>
<asp:DynamicControl ID="DynamicControl1" runat="server" DataField="Authorized"
Mode="Edit" />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblAuthorized" runat="server" Text='<%# GetBooleanText(Eval("authorized")) %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:DynamicField DataField="CreateDateTime" DataFormatString="{0:d}"
HeaderText="CreateDateTime" />
<asp:CommandField HeaderText="Delete" ShowDeleteButton="True" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:PlanetWroxConnectionString1 %>"

SelectCommand="SELECT [Id], [Title], [Authorized], [CreateDateTime] FROM [Review] WHERE ([GenreId] = @GenreId)"
DeleteCommand="DELETE FROM [Review] WHERE [Id] = @Id"
InsertCommand="INSERT INTO [Review] ([Title], [Authorized], [CreateDateTime]) VALUES (@Title, @Authorized, @CreateDateTime)"
UpdateCommand="UPDATE [Review] SET [Title] = @Title, [Authorized] = @Authorized, [CreateDateTime] = @CreateDateTime WHERE [Id] = @Id">
<DeleteParameters>
<asp:Parameter Name="Id" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Authorized" Type="Boolean" />
<asp:Parameter Name="CreateDateTime" Type="DateTime" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="GenreId"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Authorized" Type="Boolean" />
<asp:Parameter Name="CreateDateTime" Type="DateTime" />
<asp:Parameter Name="Id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:PlanetWroxConnectionString1 %>"
SelectCommand="SELECT [Id], [Name] FROM [Genre] ORDER BY [SortOrder]">
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
 
Old March 6th, 2011, 09:02 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,

That's what I thought. Your GridView coontans DynamicFields, for some reason. When you modify the columns, do you see the same options as in Figure 12-12 or do you have other options? You should choose the fields from the Bound Fields list.

When you created the site back in Chapter 2, did you create the correct type? E.g. the ASP.NET Empty web site?

Take a look at the source that comes with the book to see the differences.

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 March 6th, 2011, 10:14 PM
Authorized User
 
Join Date: Mar 2011
Posts: 12
Thanks: 2
Thanked 0 Times in 0 Posts
Default Thank you!

You are right. Had bound fields and dynamic fields options available in the full list - this time picked the bound fields. It didnt specify to use bound fields in the book so thats why I didnt really look deep into the list.
Works great now! Thanks for your very quick responses!

Howard
 
Old March 7th, 2011, 04:06 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I am not sure why you see those fields. I tried a couple of sites in various flavours of Visual Studio and never see those fields appear when I choose the standard ASP.NET Website template.

Anyway, glad you figured it out.

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
Chapter 12, Customizing GridView Columns Wilfredo Rosado BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 6 June 4th, 2010 03:46 PM
Chap. 12; Error in GetServiceInfo package ... help Pixiball BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 0 January 6th, 2009 11:03 AM
Running in Localhost but Error in Web ! nidhinasthra Classic ASP Basics 2 August 10th, 2005 06:12 AM
Error while running a web application Param .NET Web Services 9 October 8th, 2004 02:29 PM





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