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 June 14th, 2011, 10:49 AM
Registered User
 
Join Date: Jun 2011
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
Default Try It Out p.404

Hi Imar,

Thank you for your help last week with chapter 11, I got it to work fine after your help, but now Im stuck on a part of chapter 12! I was doing the 'Try it Out' exercise on page 404 'Customizing GridView Columns' and I followed the steps exactly (and repeated the exercise 3 times to make sure) but when I try and compile the page I keep getting this message:-


Server Error in '/' Application.
--------------------------------------------------

Compiler Error Message: CS1061: 'ASP.management_reviews_aspx' does not contain a definition for 'SqlDataSource2_Selecting' and no extension method 'SqlDataSource2_Selecting' accepting a first argument of type 'ASP.management_reviews_aspx' could be found (are you missing a using directive or an assembly reference?)

Source Error:



Line 14: </asp:SqlDataSource>
Line 15:
Line 16: <asp:SqlDataSource ID="SqlDataSource2" runat="server"
Line 17: ConnectionString="<%$ ConnectionStrings:PlanetWroxConnectionString1 %>"
Line 18:

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


I have seen some other people also having trouble on this exercise but none seem to have the same issue that I have.

I would be really grateful for any help you could provide!
Thanks!
 
Old June 14th, 2011, 10:51 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Can you provide the full markup and the code behind of the page?

When you post the code, please paste it in Notepad first to remove color coding and then use the forum editor's Code toolbar button to wrap your code in code tags. Otherwise, this forum messes up the code.

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 June 14th, 2011, 11:44 AM
Registered User
 
Join Date: Jun 2011
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Hi Imar,

Thank you for your reply I have posted the full markup and code behind of the Review.aspx page in the Management folder.


Code:
<%@ Page Title="Planet Wrox - Management - Reviews" Language="C#" MasterPageFile="~/MasterPages/ManagementMaster.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="ContentPlaceHolder1" Runat="Server">
    <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True" 
        AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="Name" 
        DataValueField="ID">
        <asp:ListItem Value="">Please 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:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PlanetWroxConnectionString1 %>" 
        
        SelectCommand="SELECT [ID], [Title], [Authorized], [CreateDateTime] FROM [Review]" 
        DeleteCommand="DELETE FROM [Review] WHERE [ID] = @ID" 
        InsertCommand="INSERT INTO [Review] ([Title], [Authorized], [CreateDateTime]) VALUES (@Title, @Authorized, @CreateDateTime)" 
        onselecting="SqlDataSource2_Selecting" 
        
        
        UpdateCommand="UPDATE [Review] SET [Title] = @Title, [Authorized] = @Authorized, [CreateDateTime] = @CreateDateTime WHERE [ID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <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>
        <InsertParameters>
            <asp:Parameter Name="Title" Type="String" />
            <asp:Parameter Name="Authorized" Type="Boolean" />
            <asp:Parameter Name="CreateDateTime" Type="DateTime" />
        </InsertParameters>
    </asp:SqlDataSource>

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="ID" DataSourceID="SqlDataSource2">
        <Columns>
            <asp:TemplateField HeaderText="Authorized" SortExpression="Authorized">
                <ItemTemplate>
                    <asp:Label ID="lblAuthorized" runat="server" Text='<%# GetBooleanText(Eval("Authorized")) %>'/>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="CreateDateTime" HeaderText="CreateDateTime" 
                SortExpression="CreateDateTime" DataFormatString="{0:g}" />
            <asp:HyperLinkField DataNavigateUrlFields="Id" 
                DataNavigateUrlFormatString="AddEditReview.aspx?Id={0}" DataTextField="Title" 
                HeaderText="Title" />
            <asp:CommandField HeaderText="Delete" ShowDeleteButton="True" />
        </Columns>
    </asp:GridView>
  
    </asp:Content>
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)
    {

    }
}
Thanks for all your help!
 
Old June 14th, 2011, 12:14 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

See this?

Code:
 
 onselecting="SqlDataSource2_Selecting"
With this code, you're telling the compiler to look for a method called SqlDataSource2_Selecting in the Code Behind. However, you don't have one. Maybe you accidentally double-clicked the control and then undid the changes to the code behind, but not to the markup?

If you don't need it, simply remove SqlDataSource2_Selecting from the control in mark up.

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!
The Following User Says Thank You to Imar For This Useful Post:
Soccerguy (June 14th, 2011)
 
Old June 14th, 2011, 03:28 PM
Registered User
 
Join Date: Jun 2011
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Hi Imar,

wow you are a genius! You got it spot on, I double-clicked the control by accident when I first started. I hope one day I can be as knowledgeable as you are!

Thanks again!





Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I fake a 404? inad ASP.NET 2.0 Basics 1 November 13th, 2007 09:02 PM
Status 404 for 404 page marun BOOK: Professional Apache Tomcat 0 August 30th, 2005 06:45 AM
404 error DARSIN .NET Framework 2.0 1 March 24th, 2005 06:04 AM
Error 404 jackps Dreamweaver (all versions) 2 January 15th, 2004 09:29 AM
HTTP 404 - again javacelt JSP Basics 1 November 1st, 2003 06:16 PM





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