PC Review


Reply
Thread Tools Rate Thread

DataList control column

 
 
David C
Guest
Posts: n/a
 
      10th Jan 2008
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


 
Reply With Quote
 
 
 
 
Peter Bromberg [C# MVP]
Guest
Posts: n/a
 
      10th Jan 2008
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


"David C" wrote:

> 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
>
>
>

 
Reply With Quote
 
David C
Guest
Posts: n/a
 
      10th Jan 2008
Thanks Peter. I have done things in RowDataBound in a GridView but never
anything with a DataList.

David
"Peter Bromberg [C# MVP]" <(E-Mail Removed)> wrote in message
news:A216BB3B-AF54-4FE3-A5DC-(E-Mail Removed)...
> 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
>
>
> "David C" wrote:
>
>> 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
>>
>>
>>



 
Reply With Quote
 
David C
Guest
Posts: n/a
 
      10th Jan 2008
Wait...there is no "ID" to use FindControl. It is a DataList and the column
is a HyperLink.

David
"Peter Bromberg [C# MVP]" <(E-Mail Removed)> wrote in message
news:A216BB3B-AF54-4FE3-A5DC-(E-Mail Removed)...
> 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
>
>
> "David C" wrote:
>
>> 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
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get value from column in Datalist into variable Sharon Microsoft ASP .NET 2 26th Oct 2010 03:37 PM
HOW: Finding checkbox control with a datalist control =?Utf-8?B?SlA=?= Microsoft Dot NET 1 8th Jun 2006 06:24 AM
Finding all matches in column B with datalist in column A =?Utf-8?B?UG9wcyBKYWNrc29u?= Microsoft Excel Programming 3 11th Apr 2006 08:10 PM
DataList column alignment? =?Utf-8?B?QmVuIEZpZGdl?= Microsoft ASP .NET 5 22nd Jun 2005 10:54 PM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll Microsoft ASP .NET 8 9th Sep 2004 11:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:51 AM.