G
Guest
All I need to do is set the border property of an image control to border=0.
I want to do this at runtime for the first image on the page in a datalist.
In the ItemCreated event I'm trying to use FindControl to set a reference to
the img control so I can change the attribute. But when I run the code below
I get the error: "Object reference not set to an instance of an object." I
assume its not finding the control and returning null? Anyway, you can see
what I'm trying to do, can anyone tell me how to get it to work? (code below)
******* code *******
public void main_ItemCreated(Object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item)
{
HtmlImage imgPatron = new HtmlImage();
imgPatron = (HtmlImage)e.Item.FindControl(Request.Form["patron"]);
if(imgPatron!=null)
{
image_count();
if(i_count == 1)
{
imgPatron.Border = 0;
}
}
}
************
Thanks for any help!
I want to do this at runtime for the first image on the page in a datalist.
In the ItemCreated event I'm trying to use FindControl to set a reference to
the img control so I can change the attribute. But when I run the code below
I get the error: "Object reference not set to an instance of an object." I
assume its not finding the control and returning null? Anyway, you can see
what I'm trying to do, can anyone tell me how to get it to work? (code below)
******* code *******
public void main_ItemCreated(Object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item)
{
HtmlImage imgPatron = new HtmlImage();
imgPatron = (HtmlImage)e.Item.FindControl(Request.Form["patron"]);
if(imgPatron!=null)
{
image_count();
if(i_count == 1)
{
imgPatron.Border = 0;
}
}
}
************
Thanks for any help!