Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4.5.1 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5.1: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-84677-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5.1 : 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 December 27th, 2015, 11:57 AM
Authorized User
 
Join Date: Nov 2014
Posts: 91
Thanks: 2
Thanked 1 Time in 1 Post
Default Chapter 13: Setting Up the Filter

Hi Imar,

I backtracked to Chapter 13 and found an error that creeped into the Reviews.aspx code: Error Creating Control - SqlDataSource2. The end tag is missing for <asp:SqlDataSource ID="SqlDataSource2"...

Here is my code.
Code:
<%@ Page Title="Planet Wrox - Management - Reviews" Language="C#" MasterPageFile="~/MasterPages/Management.master" 
  AutoEventWireup="true" CodeFile="Reviews.aspx.cs" Inherits="Management_Review" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
  <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True" AutoPostBack="True" 
    DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="Id">
    <asp:ListItem Value="" >Make a selection</asp:ListItem>
  </asp:DropDownList>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:PlanetWroxConnectionString1 %>"
    SelectCommand="SELECT [Id], [Name] FROM [Genre]   ORDER BY [SortOrder]" ></asp:SqlDataSource>
    <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 HeaderText="Authorized" SortExpression="Authorized">
         <ItemTemplate>
            <asp:Label ID="AuthorizedLabel1" runat="server" Text='<%# GetBooleanText(Eval("Authorized")) %>'></asp:Label>
        </ItemTemplate>
      </asp:TemplateField>
      <asp:BoundField DataField="CreateDateTime" DataFormatString="{0:g}" HeaderText="CreateDateTime" 
        SortExpression="CreateDateTime" />
      <asp:CommandField HeaderText="Delete" ShowDeleteButton="True" />
    </Columns>
  </asp:GridView>
  <a href="AddEditReview.aspx">Insert New Review</a>
  <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:PlanetWroxConnectionString1 %>" 
    DeleteCommand="DELETE FROM [Review] WHERE [Id] = @Id" 
    InsertCommand="INSERT INTO [Review] ([Title], [Authorized], [CreateDateTime]) VALUES (@Title, @Authorized, @CreateDateTime)" 
    SelectCommand="SELECT [Id], [Title], [Authorized], [CreateDateTime] FROM [Review] WHERE ([GenreId] = @GenreId)" 
    UpdateCommand="UPDATE [Review] SET [Title] = @Title, [Authorized] = @Authorized, [CreateDateTime] = @CreateDateTime 
    WHERE [Id] = @Id"><\asp:SqlDataSource>
    <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:Content>
I checked my code, and it appears to me that the end tag is there. I also get a green squiggly line under "SqlDataSource" for "SqlDataSource2".

Last edited by phztfte1; December 27th, 2015 at 12:00 PM.. Reason: Wrong Title and not all code appeared.
 
Old January 10th, 2016, 12:22 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 checked my code, and it appears to me that the end tag is there. I also get a green squiggly line under "SqlDataSource" for "SqlDataSource2".

You may want to check it again:

[CreateDateTime] = @CreateDateTime
WHERE [Id] = @Id"><\asp:SqlDataSource>

The end tag is in the wrong location and it's format is invalid (should be </asp:SqlDataSource>)

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 January 10th, 2016, 10:04 PM
Authorized User
 
Join Date: Nov 2014
Posts: 91
Thanks: 2
Thanked 1 Time in 1 Post
Smile Chapter 13: Setting Up the Filter

Imar,

Thank you. Problem is fixed. No more error message.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch13: Problem with "Setting up the Filter" P467 axelle BOOK: Beginning ASP.NET 4.5 : in C# and VB 6 February 25th, 2015 01:53 AM
Setting up a GridView Filter with a BoundField ssezotman BOOK: Beginning ASP.NET 4.5 : in C# and VB 9 December 13th, 2014 07:23 PM
Chapter 13 - Applying the Filter okason BOOK: Beginning ASP.NET 4 : in C# and VB 4 August 22nd, 2012 07:54 AM
Chapter 3 - Filters - Current Filter hixsonb BOOK: Professional WordPress Plugin Development 0 March 8th, 2012 03:50 PM
Chpt 13 Setting up a filter ja11946 BOOK: Beginning ASP.NET 4 : in C# and VB 1 December 3rd, 2010 03:43 PM





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