By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,919 Members | 1,600 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,919 IT Pros & Developers. It's quick & easy.

How to list out table items in aspx?

P: n/a

I created a table with a field to store the full path of the uploading images

The table scheme is
path //path to the uploading imag
userid //who upload i

Now, I want to display the image path in url, it only shows the images belong to that user. User can see that image by clicking the hyperlink

Here is the code

protected System.Web.UI.WebControls.HyperLink lnkAttachement

private string GetPath(int id

string sql
SqlDataReader dr

sql = "Select path From upload Where userid='" + id.ToString() + "'"

dr = SqlHelper.ExecuteReader(Connection,System.Data.Com mandType.Text,sql)

this.lnkAttachement.Text = Path.GetFileName(dr["path"].ToString())
this.lnkAttachement.NavigateUrl = stringDirectory + Server.UrlEncode(Path.GetFileName(dr["path"].ToString()))




dr.Read() cannot read the whole table and put them to the url.

How should I write it

Thanks for help
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies

P: n/a

It shows

1. only the first file name, it cannot show all file in a list form lik

It only shows a.jpg even though there are many path in the DB

2. When I mouse over the path link, it shows "file:///C:/webapplication/images/a.jpg.

But, what did I want to display is

How can I fix those 2 problems

I am not sure what should I use to replace read(). Could you help

Nov 18 '05 #2

P: n/a
Hi, Tom

Try the following
(HyperLink) lnkAttachement1
stringDirectory = ""
while (dr.Read()

lnkAttachement1 = new HyperLink()
lnkAttachement1.Text = dr["path"].ToString()
lnkAttachement1.NavigateUrl = stringDirectory + Server.UrlEncode(dr["path"].ToString())
Bin Song, MCP
Nov 18 '05 #3

P: n/a

It works now!

Only 2 things

1. It displays the whole link lik


How can I show them lik

2. It shows below the upload button on the page. How can I show it on lnkAttachement1?

Because I have the tag of <asp:HyperLink ID="lnkAttachement1" Runat="server" /> insides a row of a table in aspx

Thank you for teaching me.
Nov 18 '05 #4

P: n/a
Then why not use datagrid or datalist? You can just directly bind data and add a delete button on the fly

Bin Song, MCP
Nov 18 '05 #5

P: n/a
Hi, Tom,

Glad that you finished your project. You are welcome.
I am in Canada. Programming is my job.

Bin Song, MCP
Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.