Guys. I am doing a social portal website over here. And i am facin ths problem whereby whenever i retrieve new updates from my database, I can only show one user's update.
In the case below, i only can show the username Weihao wrote a new note. By right, the following "wrote a new note" sentences shld appear a username infront of it. Could you guys help me examine my code.
My idea was to actually repeat the hyperlink. Do you all think it can work?
For Example
Weihaowrote a new note.
HAHAHAHAA.
wrote a new note.
Hello.
wrote a new note.
saasdasd.
wrote a new note.
yoyoyo.
Codes
---------------------------------------------------------------------------------------------------------------------------------
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;
publicpartialclass_Default : System.Web.UI.Page
{
protected void Button1_Click(
object sender,
EventArgs e)
{
lblResult.Text =
"";
String strConString =
ConfigurationManager.ConnectionStrings[
"SocialSystemConnectionString"].ConnectionString;
SqlConnection con =
new SqlConnection();
con.ConnectionString = strConString;
//create Command
SqlCommand cmd =
new SqlCommand(
"SELECT Types.TypeID, [Update].TextInput, [User].FullName FROM Types INNER JOIN [Update] ON Types.TypeID = [Update].TypeId INNER JOIN [User] ON [Update].Email = [User].Email WHERE [Update].TypeId = 1", con);
// Open Connection
con.Open();
//Execute Command
SqlDataReader reader = cmd.ExecuteReader();
//Read and display data
//int Counthyper = 0;
while (reader.Read())
{
HyperLink1.NavigateUrl =
"http://localhost/Profile.aspx?userid=";
HyperLink1.Text = reader[
"FullName"].ToString();
//Counthyper++;
lblResult.Text +=
"wrote a new note" +
"." +
"<br/>" +
"<br/>" + reader[
"TextInput"].ToString() +
"." +
"<br/>" +
"<br/>";
}
//Close Reader
reader.Close();
con.Close();
HyperLink1.Visible =
true;
lblResult.Visible =
true;
}