PC Review


Reply
Thread Tools Rate Thread

DataList Columns

 
 
MikeB
Guest
Posts: n/a
 
      2nd Jun 2007
I have a datalist with 2 columns (RepeatColumns = 2) that displays photos.
The photo url is based on a value in the Web.Config so I have to set the
url on the databoud event. Although this work fine on the first image, it
doesn't work and the second image and the event doesnt seem to be fired.
Any idea what I am doing wrong or a better way to do this? Below is my
databound method.


protected void dlPhotos_databound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item)
{
HyperLink hl = (HyperLink)e.Item.FindControl("HyperLink1");
Image img = (Image)e.Item.FindControl("Image1");

hl.NavigateUrl =
System.Configuration.ConfigurationManager.AppSettings.Get("HostURL") +
"Handler.ashx?Size=O&PhotoID=" +
dlPhotos.DataKeys[e.Item.ItemIndex].ToString() + "&CompanyID=" +
Constants.CompanyID.ToString();
img.ImageUrl =
System.Configuration.ConfigurationManager.AppSettings.Get("HostURL") +
"Handler.ashx?Size=300&PhotoID=" +
dlPhotos.DataKeys[e.Item.ItemIndex].ToString() + "&CompanyID=" +
Constants.CompanyID.ToString();
}
}


 
Reply With Quote
 
 
 
 
MikeB
Guest
Posts: n/a
 
      2nd Jun 2007
I changed my code to this and it started working correctly, thanks for
looking.


protected void dlPhotos_databound(object sender, DataListItemEventArgs e)

{

HyperLink hl = (HyperLink)e.Item.FindControl("HyperLink1");

Image img = (Image)e.Item.FindControl("Image1");

if(hl != null && img != null)

{


hl.NavigateUrl =
System.Configuration.ConfigurationManager.AppSettings.Get("HostURL") +
"Handler.ashx?Size=O&PhotoID=" +
dlPhotos.DataKeys[e.Item.ItemIndex].ToString() + "&CompanyID=" +
Constants.CompanyID.ToString();

img.ImageUrl =
System.Configuration.ConfigurationManager.AppSettings.Get("HostURL") +
"Handler.ashx?Size=300&PhotoID=" +
dlPhotos.DataKeys[e.Item.ItemIndex].ToString() + "&CompanyID=" +
Constants.CompanyID.ToString();

}

}



"MikeB" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a datalist with 2 columns (RepeatColumns = 2) that displays photos.
>The photo url is based on a value in the Web.Config so I have to set the
>url on the databoud event. Although this work fine on the first image, it
>doesn't work and the second image and the event doesnt seem to be fired.
>Any idea what I am doing wrong or a better way to do this? Below is my
>databound method.
>
>
> protected void dlPhotos_databound(object sender, DataListItemEventArgs e)
> {
> if (e.Item.ItemType == ListItemType.Item)
> {
> HyperLink hl = (HyperLink)e.Item.FindControl("HyperLink1");
> Image img = (Image)e.Item.FindControl("Image1");
>
> hl.NavigateUrl =
> System.Configuration.ConfigurationManager.AppSettings.Get("HostURL") +
> "Handler.ashx?Size=O&PhotoID=" +
> dlPhotos.DataKeys[e.Item.ItemIndex].ToString() + "&CompanyID=" +
> Constants.CompanyID.ToString();
> img.ImageUrl =
> System.Configuration.ConfigurationManager.AppSettings.Get("HostURL") +
> "Handler.ashx?Size=300&PhotoID=" +
> dlPhotos.DataKeys[e.Item.ItemIndex].ToString() + "&CompanyID=" +
> Constants.CompanyID.ToString();
> }
> }
>



 
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
Datalist columns lee atkinson Microsoft ASP .NET 1 26th Oct 2010 03:41 PM
DataList & dynamic columns John Devlon Microsoft ASP .NET 1 25th Nov 2009 08:25 AM
Newbie: DataList with 2 Columns Joao Batista Microsoft ASP .NET 1 9th Mar 2006 01:58 PM
formatting a datalist into columns? Please Help Moe Sizlak Microsoft ADO .NET 2 2nd Aug 2004 03:29 PM
display columns from 2 tables in datalist Joe Van Meer Microsoft ASP .NET 0 7th May 2004 03:43 PM


Features
 

Advertising
 

Newsgroups
 


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