Can I bind an array to GridView to show hyperlinked columns?

I

ianstirkcv

Hi,

Does anyone have an ASP 2.0 code sample that shows how to bind a
one-dimensional array to a GridView, such that the rows are shown as
hyperlinks?

Thanks
Ian
 
A

Aytaç ÖZAY

Hi,

It is possible that if you use ListItem for items that store in arrays, the
below is a sample code that works fine. Only to do is setting that the
gridview has a hyperlinkfield and set DataNavigateUrlFields to "Text" and
set DataTextFields set to "Text".
If you want to use visible link name is different than the target then you
can use ListItem's "Value" property and set them in Arrays then change the
DataTextFields set to "Value".

If you use ArrayList:
ArrayList myListItem = new ArrayList();

myListItem.Add(new ListItem("http://www.yahoo.com"));

myListItem.Add(new ListItem("http://www.microsoft.com"));

GridView1.DataSource = myListItem;

GridView1.DataBind();



If you use ListItem Array:
ListItem[] myListItem = new ListItem[2];

myListItem[0]=new ListItem("www.yahoo.com");

myListItem[1]=new ListItem("www.microsoft.com");

GridView1.DataSource = myListItem;

GridView1.DataBind();

Have a nice work,

Aytaç ÖZAY
Software Developer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top