DataList control column

  • Thread starter Thread starter David C
  • Start date Start date
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
 
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
 
Thanks Peter. I have done things in RowDataBound in a GridView but never
anything with a DataList.

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

David
 
Back
Top