Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 9th, 2011, 07:09 AM
Authorized User
Points: 285, Level: 5
Points: 285, Level: 5 Points: 285, Level: 5 Points: 285, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2010
Posts: 71
Thanks: 12
Thanked 0 Times in 0 Posts
Default CH13 page 460 - not working!

CH13 page 460

Ive done this before following the book and all went well. I am now doing it with my own design. But I am not getting any table showing on the AddEdit page once a user chooses an option on the page before. For this page I am using the ASPNETDB database to show an Admin user who the users are...

Here is the code for the selection page:

Code:
<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminMasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Admin_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
    DataSourceID="SqlDataSource1">
    <Columns>
        <asp:HyperLinkField DataNavigateUrlFields="UserName" 
            DataNavigateUrlFormatString="addEditUser.aspx?UserName={0}" 
            DataTextField="UserName" HeaderText="User Name" />
        <asp:BoundField DataField="UserId" HeaderText="User ID" 
            SortExpression="UserId" />
        <asp:BoundField DataField="LastActivityDate" HeaderText="Last Date Active" 
            SortExpression="LastActivityDate" />
        <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
    </Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
    
    
        SelectCommand="SELECT u.UserId, u.UserName, u.LastActivityDate, m.Email FROM vw_aspnet_Users AS u INNER JOIN aspnet_Membership AS m ON u.UserId = m.UserId ORDER BY LastActivityDate DESC">
</asp:SqlDataSource>

</asp:Content>
and the code for the addEdit page:

Code:
<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminMasterPage.master" AutoEventWireup="true" CodeFile="addEditUser.aspx.cs" Inherits="Admin_addEditUser" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<h2>Edit the user here!</h2>
    <p>
        <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
            DataSourceID="SqlDataSource1" DefaultMode="Insert" Height="50px" Width="125px">
            <Fields>
                <asp:BoundField DataField="UserId" HeaderText="UserId" 
                    SortExpression="UserId" />
                <asp:BoundField DataField="UserName" HeaderText="UserName" 
                    SortExpression="UserName" />
                <asp:BoundField DataField="LastActivityDate" HeaderText="LastActivityDate" 
                    SortExpression="LastActivityDate" />
            </Fields>
        </asp:DetailsView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT UserId, UserName, LastActivityDate FROM aspnet_Users WHERE (UserName = @UserName)">
            <SelectParameters>
                <asp:Parameter Name="UserName" />
            </SelectParameters>
        </asp:SqlDataSource>
    </p>
</asp:Content>
And the code behind for the addEdit page:

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 Admin_addEditUser : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString.Get("UserName") !=null)
        {
            DetailsView1.DefaultMode = DetailsViewMode.Edit;
        }
    }
}
This is what the browser string looks like:
Code:
http://localhost:49431/clientManagerTest/Admin/addEditUser.aspx?UserName=bbb
Do you know why the addEdit page is blank after selection?
Reply With Quote
  #2 (permalink)  
Old December 10th, 2011, 04:27 AM
Imar's Avatar
Wrox Author
Points: 72,045, Level: 100
Points: 72,045, Level: 100 Points: 72,045, Level: 100 Points: 72,045, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,083
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

Maybe you SqlDataSource1 needs a QueryStringParameter rather than a plain Parameter in its SelectParameters?

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!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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
Ch13 Page 457 Step 12 ken evans BOOK: Beginning ASP.NET 4 : in C# and VB 1 October 25th, 2010 06:37 AM
Chapter 13, Try It out p.460 Apprentice75 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 4 July 9th, 2010 12:46 PM
Chapter 13 Try It Out Pg. 460 Broken Images workib BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 4 September 19th, 2008 10:29 AM
Ch13 Case Study 2 alecwood BOOK: Beginning Access 2003 VBA 0 October 18th, 2007 05:40 AM



All times are GMT -4. The time now is 06:14 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.