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?