Wrox Programmer Forums
|
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 October 25th, 2010, 06:26 AM
Authorized User
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2010
Posts: 56
Thanks: 17
Thanked 2 Times in 2 Posts
Default Ch13 Page 457 Step 12

I can open Reviews.aspx in the browser.
However, When I choose a Genre in the DropDownList, the postback happens but I don't see the list of reviews.

I compared my code with the downloaded source but I can't see any differences.

One small point, the three Management hyperlinks appear above the drop-down list and not to its left.

Any clues?

Thanks
Ken

Here is the code:

Management>Reviews.aspx
Code:
 
<%@ Page Title="Planet Wrox - Management - Reviews" Language="C#" MasterPageFile="~/MasterPages/Management.master" AutoEventWireup="true" CodeFile="Reviews.aspx.cs" Inherits="Management_Reviews" %>
<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: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="AuthorizedLabel" runat="server" Text='<%# GetBooleanText(Eval("Authorized")) %>' />
        </ItemTemplate>
      </asp:TemplateField>
      <asp:BoundField DataField="CreateDateTime" HeaderText="CreateDateTime" 
        SortExpression="CreateDateTime" DataFormatString="{0:g}" />
      <asp:CommandField HeaderText="Delete" ShowDeleteButton="True" />
    </Columns>
  </asp:GridView>
  <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
    ConnectionString="<%$ ConnectionStrings:PlanetWroxConnectionString1 %>" 
    
    SelectCommand="SELECT [Id], [Title], [CreateDateTime], [Authorized] FROM [Review] WHERE ([GenreId] = @GenreId)" 
    DeleteCommand="DELETE FROM [Review] WHERE [Id] = @Id" 
    InsertCommand="INSERT INTO [Review] ([Title], [CreateDateTime], [Authorized]) 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="CreateDateTime" Type="DateTime" />
      <asp:Parameter Name="Authorized" Type="Boolean" />
    </InsertParameters>
    <SelectParameters>
      <asp:ControlParameter ControlID="GridView1" 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>
</asp:Content>
Management>Reviews.aspx.cs
Code:
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Management_Reviews : System.Web.UI.Page
{
  protected string GetBooleanText(object booleanValue)
  {
    bool authorized = (bool)booleanValue;
    if (authorized)
    {
      return "Yes";
    }
    else
    {
      return "No";
    }
  }

  protected void Page_Load(object sender, EventArgs e)
  {

  }
}
MasterPages>Management.Master
Code:
 

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Management.master.cs" Inherits="MasterPages_Management" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <div style="width: 200px; float: left;"></div>
      <ul>
        <li><a href="~/Management/Default.aspx" runat="server">Management Home</a> </li>
        <li><a href="~/Management/Genres.aspx" runat="server">Manage Genres</a></li>
        <li><a href="~/Management/Reviews.aspx" runat="server">Manage Reviews</a></li>
        
      </ul>
     <div style="width: 750px; float; left;">  
        <asp:ContentPlaceHolder id="cpMainContent" runat="server">
        </asp:ContentPlaceHolder>
    </div>
    </div>
    </form>
</body>
</html>

MasterPages>Management.Master.cs
Code:
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class MasterPages_Management : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}
 
Old October 25th, 2010, 06:37 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

My source:

Code:
 
<SelectParameters>
  <asp:ControlParameter ControlID="DropDownList1" Name="GenreId" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
Your source:

Code:
 
<SelectParameters>
  <asp:ControlParameter ControlID="GridView1" Name="GenreId" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
You linked it to the GridView instead of the DropDownLisdt.

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:
ken evans (October 25th, 2010)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch13 Page 443 - Step 5 problem ken evans BOOK: Beginning ASP.NET 4 : in C# and VB 11 July 27th, 2011 01:35 PM
Question about step 12 on page 94 bryman BOOK: Beginning iPad Application Development 4 December 20th, 2010 03:01 PM
page 457 results Dan Cern BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 August 31st, 2009 05:09 AM
Page 417 step 12 "Bound to:" field Dan Cern BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 August 24th, 2009 12:15 PM
Chapter 12 - Page 406 - Step 9 - Not showing up this way? jn148 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 7 December 14th, 2008 12:58 PM





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