Reputation: 77
I am try to set img height which bind in repeater. But i can't :
HtmlImage proImg = item.FindControl("proImg") as HtmlImage;
proImg.Attributes.Add("style", "height:407px;");
can any one give me solution?
Upvotes: 4
Views: 466
Reputation: 8271
This can be done using the ItemDataBound
public void Repeater_ItemDataBound(Object Sender, RepeaterItemEventArgs e) {
if (e.Item.ItemType == ListItemType.Item
|| e.Item.ItemType == ListItemType.AlternatingItem)
{
// I'm assuming you are using HTML img tags
HtmlImage proImg = e.Item.FindControl("proImg") as HtmlImage;
proImg.Attributes.Add("style", "height:407px;");
}
}
Upvotes: 1
Reputation: 205
You can directly use height in Image tag like:
<asp:Image Height="407" />
This is the simplest way and it saves lot of processing.
Upvotes: 0
Reputation: 670
Try to set:
proImg.Height = 407;
Here you have more details about HtmlImage.Height property: https://msdn.microsoft.com/en-us/en-en/library/office/system.web.ui.htmlcontrols.htmlimage.height(v=vs.71))
Upvotes: 0