DataList control column

D

David C

I have a DataList control that displays file names from a directory. I
would like to conditionally add a string to the DataNavigateUrlFormatString
in a HyperlInk column before it is displayed. Where is the best place to do
that? Currently the DataNavigateUrlFormatString="ShowDocs.aspx?doc={0}" and
I want to sometimes add a 2nd querystring value. Thanks.

David
 
P

Peter Bromberg [C# MVP]

DataList supports the ItemDataBound event, which is where you would do this
kind of "stuff":

void Item_Bound(Object sender, DataListItemEventArgs e)
{

if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{

// Retrieve the Label control in the current DataListItem.
Label PriceLabel = (Label)e.Item.FindControl("PriceLabel");
// modify the label, hyperlink, etc. here
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
 
D

David C

Thanks Peter. I have done things in RowDataBound in a GridView but never
anything with a DataList.

David
 
D

David C

Wait...there is no "ID" to use FindControl. It is a DataList and the column
is a HyperLink.

David
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top