Hi
I have below code & i want to display image using Code behind
Code
'>
'>
' />Thanks
Hi
I have below code & i want to display image using Code behind
'>
'>
' />Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Tuhin PaulRank #7 · 71.9K reputationPosted Jun 18, 2023, 11:13 AM EDT
Handling the ItemDataBound event for each item in the Repeater control can have a performance impact, especially when dealing with a large number of items. The event handler is executed for each item during data binding, which can result in slower page rendering.
Tuhin PaulRank #7 · 71.9K reputationPosted Jun 18, 2023, 11:14 AM EDT
Using the ItemDataBound event limits your flexibility in terms of controlling the rendering of the items. If you have complex logic or dynamic behavior that needs to be applied to the items, it can become challenging to manage within the event handler.
Mohamed Azarudeen ZRank #297 · 8.5K reputationPosted Jun 17, 2023, 12:25 PM EDT
Hi ramo
you can modify your code as follows:
Imagecontrol to your markup code:in your code-behind file, handle the
ItemDataBoundevent of theRepeatercontrol:protected void rptData_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { // Find the controls within the current item Literal ltrlBookTitle = (Literal)e.Item.FindControl("ltrlBookTitle"); Image imgThumb = (Image)e.Item.FindControl("imgThumb"); // Retrieve the data item bound to the current item DataRowView rowView = (DataRowView)e.Item.DataItem; // Set the BookTitle value to the Literal control ltrlBookTitle.Text = rowView["BookTitle"].ToString(); // Set the ThumbImage value to the Image control's URL property imgThumb.ImageUrl = rowView["ThumbImage"].ToString(); } }