Hello pple, sorry for the long chunk of codes.
What i am trying to do over here is, ViewAllMessages will display all the messages of a particular user, and ViewMessage will display the message content, determined by title.
The problem over here is, whenever i click on the title, it will display all the messages, not just the particular message title contents.
What exactly is the problem over here?
Code for ViewAllMessages.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ViewAllMessages.aspx.cs" Inherits="ViewPersonalMessages" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BorderStyle="None"
GridLines="None" Visible="true" Width="443px">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<br />
<table style="width: 353px; height: 96px">
<tr>
<td style="width: 54px">
<asp:Label ID="lblFrom" runat="server" Text="From:" Font-Bold="True"></asp:Label></td>
<td colspan="2">
<a href="<%# Eval("Email", "ProfilePage.aspx?Email={0}") %>">
<asp:Image ID="imgPP" runat="server" Height="50" ImageUrl='<%# Eval("UID", "testingGetImg.aspx?UID={0}") %>' Width="50" />
<br />
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Underline="True" Text='<%# Bind("FullName") %>' Font-Size="Smaller"></asp:Label></a></td>
</tr>
<tr>
<td style="width: 54px; height: 22px">
<asp:Label ID="lblDate" runat="server" Text="Date:" Font-Bold="True"></asp:Label></td>
<td colspan="2" style="height: 22px">
<asp:Label ID="datetime" runat="server" ForeColor="#C00000" Text='<%# Bind("SystemDate") %>'></asp:Label></td>
</tr>
<tr>
<td style="width: 54px; height: 21px">
<asp:Label ID="lblTitle" runat="server" Text="Title:" Font-Bold="True"></asp:Label></td>
<td colspan="2" style="height: 21px">
<asp:Label ID="lblRetrieveTitle" runat="server" Text='<%# Bind("Title") %>'></asp:Label></td>
</tr>
<tr>
<td style="width: 54px; height: 21px">
<asp:Label ID="lblMessage" runat="server" Text="Message:" Font-Bold="True"></asp:Label></td>
<td colspan="2" style="height: 21px">
<asp:Label ID="lblRetrieveMessage" runat="server" Text='<%# Bind("TextInput") %>'></asp:Label></td>
</tr>
</table>
<hr />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView><br />
<br />
</div>
</form>
</body>
</html>
Code for ViewAllMessages.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class ViewAllMessages : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string strConString = ConfigurationManager.ConnectionStrings["SocialSystemConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(strConString);
SqlCommand cmd = new SqlCommand("SELECT DISTINCT [User].UID, [User].FullName, [Message].SystemDate, [Message].Title, [Message].TextInput, [Message].Email FROM [User] INNER JOIN [Message] ON [User].Email = [Message].Email", con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
GridView1.DataSource = reader;
GridView1.DataBind();
reader.Close();
con.Close();
}
}
Code for ViewMessage.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ViewMessage.aspx.cs" Inherits="ViewMessage" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="#CCCCCC"
BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="0" DataSourceID="MessageDataSource"
ForeColor="Black" Height="187px" Width="562px">
<FooterStyle BackColor="#CCCCCC" />
<RowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="From" SortExpression="Email">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Email") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Title" SortExpression="Title">
<ItemTemplate>
<a href="<%# Eval("Title", "ViewPersonalMessages.aspx?Title={0}") %>">
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Title") %>'></asp:Label></a>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Date" SortExpression="SystemDate">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("SystemDate") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Status" SortExpression="Status">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Status") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:TemplateField>
</Columns>
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="Black" BorderStyle="Dashed" Font-Bold="True" ForeColor="White" />
<EditRowStyle BorderStyle="Dotted" HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:GridView>
<br />
<asp:SqlDataSource ID="MessageDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SocialSystemConnectionString %>"
SelectCommand="SELECT [Email], [Title], [SystemDate], [Status] FROM [Message]"></asp:SqlDataSource>
</div>
</form>
</body>
</html>