Hi All,
Thank you for taking the time to read my post.
I am currently making a Client Dashboard and am in the final steps of completing it but I cannot get the logged in users info (UserName) to pass through to the dashboard correctly display only their data from the database. I am trying to link the client records on file through a SQL Database with the logged in clients id (UserName).
I used VWD2010 Express to build the site and used the built in Login creator to build my login control.
Here is my page code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="dashboard.aspx.cs" Inherits="dashboard" %>
<!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 id="Head1" runat="server">
<title>Puckett & Redford P.L.L.C.</title>
<link rel="Stylesheet" href="styles/subpage_styles.css" type="text/css" media="screen" />
<link rel="stylesheet" href="menu/pro_dropdown_3.css" type="text/css" />
<link rel="stylesheet" href="styles/screen.css" type="text/css" media="screen,projection" />
<script src="menu/stuHover.js" type="text/javascript"></script>
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div id="menu_form" runat="server">
</div>
<div id="body_form" runat="server">
<div class="div_doublespan_narrow_wrapper_left">
<div id="body_form_subpage_picture_vert" runat="server"> </div></div>
<div style="display:inline;float:right;width:528px;">
<div style="display: block;padding:10px 10px 14px 10px;">
<table border='0' cellpadding='0' cellspacing='0' style="width:100%">
<tr>
<td style='text-align:left;vertical-align:top;width:50%'>
<div style="padding-removed10px;" class="content_header" align="left"> P &
R Client Dashboard
<asp:LoginStatus ID="LoginStatus1" runat="server"
LogoutPageUrl="~/home.aspx" LogoutAction="Redirect" />
<br />
</div></td>
</tr>
</table>
</div>
<div style="background-color:#ff0;display:block;width:528px;">
<div class="div_doublespan_narrow_wrapper_right" style="padding:15px 25px 15px 25px;width:478px;">
<div style="display: block;font-size: small;padding-removed10px;width:478px;" class="content_header">
Current Cases</div>
<div style="border:1px solid #044A79;display: block; height:300px;width:478px;">
<div id="openfiles" runat="server">
<div id="opencontainer" style="height: 283px; width: auto; overflow: scroll;"
align="center">
<asp:SqlDataSource ID="CMCLIENTDB" runat="server" OnSelecting="CMCLIENTDB_Selecting">
<SelectParameters>
<asp:Parameter Name="UserName" Type="String" Direction="Input" />
</SelectParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
BorderStyle="None" GridLines="None" Height="262px"
HorizontalAlign="Center">
<Columns>
<asp:BoundField DataField="Ndesc" HeaderText="Defendants(s) Full Name(s)"
SortExpression="Ndesc" />
<asp:BoundField DataField="Apart_No"
HeaderText="Building/Apartment No." SortExpression="Apart_No" />
<asp:BoundField DataField="Sc_Srvd" DataFormatString="{0:MM/dd/yyyy}"
HeaderText="Summons & Complaint Served On" SortExpression="Sc_Srvd" />
<asp:BoundField DataField="R_Date" DataFormatString="{0:MM/dd/yyyy}"
HeaderText="Return Date" SortExpression="R_Date" />
<asp:BoundField DataField="Osc_Date" DataFormatString="{0:MM/dd/yyyy}"
HeaderText="Show Cause Date" SortExpression="Osc_Date" />
<asp:BoundField DataField="Close_Date" DataFormatString="{0:MM/dd/yyyy}"
HeaderText="Close Date" SortExpression="Close_Date" />
</Columns>
</asp:GridView>
</div>
</div>
</div>
</div>
<br />
<div class="div_doublespan_narrow_wrapper_right" style="padding:15px 25px 15px 25px;width:478px;">
<div style="display: block;font-size: small;padding-removed10px;width:478px;" class="content_header">
Closed Cases <span style="color: #5F0100; ">(120-Day History)</span></div>
<div style="border:1px solid #044A79;display: block; height:300px;width:478px;">
<div id="closedfiles" runat="server">
<div id="closedcontainer" style="height: 283px; width: auto; overflow: scroll;"
align="center">
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
DataSourceID="CMCLIENTDB2" BorderStyle="None" GridLines="None" Height="262px"
HorizontalAlign="Center">
<Columns>
<asp:BoundField DataField="Ndesc" HeaderText="Defendants(s) Full Name(s)"
SortExpression="Ndesc" />
<asp:BoundField DataField="Apart_No"
HeaderText="Building/Apartment No." SortExpression="Apart_No" />
<asp:BoundField DataField="Sc_Srvd" DataFormatString="{0:MM/dd/yyyy}"
HeaderText="Summons & Complaint Served On" SortExpression="Sc_Srvd" />
<asp:BoundField DataField="R_Date" DataFormatString="{0:MM/dd/yyyy}"
HeaderText="Return Date" SortExpression="R_Date" />
<asp:BoundField DataField="Osc_Date" DataFormatString="{0:MM/dd/yyyy}"
HeaderText="Show Cause Date" SortExpression="Osc_Date" />
<asp:BoundField DataField="Close_Date" DataFormatString="{0:MM/dd/yyyy}"
HeaderText="Close Date" SortExpression="Close_Date" />
</Columns>
</asp:GridView>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="div_span_clear">
</div>
</div>
<div id="head_form" runat="server">
</div>
<div id="foot_form" runat="server">
</div>
<div id="overflow" runat="server"></div>
</form>
</body>
</html>
And my C# Code on the backend:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class dashboard : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Draw();
}
protected void CMCLIENTDB_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
e.Command.Parameters["@UserName"].Value = User.Identity.Name;
string connection = "Data Source=(hidden, i know this part works)";
string qry1 = "SELECT [Ndesc],[Apart_No],[Sc_Srvd],[R_Date],[Osc_Date],[Close_Date] FROM [hidden, i know this part works].[hidden, i know this part works].[CMCLIENT] WHERE [Client_ID] like @UserName + '.%' AND ([Close_Date] > (CURRENT_TIMESTAMP-1) OR [Close_Date] is Null)";
SqlConnection con;
SqlCommand cmd;
SqlDataSource sds;
con = new SqlConnection(connection);
cmd = new SqlCommand(qry1, con);
sds = new SqlDataSource(connection, qry1);
GridView1.DataSource = sds;
GridView1.DataBind();
}
protected void Draw()
{
menu_form.InnerHtml = menu.drawDashboardMenu();
head_form.InnerHtml = draw.drawHeader();
foot_form.InnerHtml = draw.drawFooter();
}
}
Thank you guys so much for any help that can be offered. I know i'm close!
- Conor
ASP.NET Beginner