Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 9th, 2009, 11:25 PM
Authorized User
 
Join Date: Jan 2009
Posts: 23
Thanks: 8
Thanked 0 Times in 0 Posts
Default Using repeater to repeat Hyperlinks

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;
}
 
Old March 10th, 2009, 06:30 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

mmm.. Yep, It could work if you use a repeater.. right now it will just drop all the rows except the last one, because you are writing the text always in the same place.
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT - Don't Repeat if last record mattboy_slim XSLT 2 September 11th, 2007 12:33 PM
InStr() repeat instances spinout Classic ASP Components 7 November 23rd, 2006 11:55 AM
no repeat selection! masgas MySQL 2 February 18th, 2006 01:17 PM
Sort a repeat region hendricksonet VBScript 0 August 11th, 2005 01:55 PM
Repeat Region with a difference. fatmcgav Dreamweaver (all versions) 2 January 17th, 2005 05:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.