Hi ramco1917,
Please refer the below sample.
HTML
<asp:Repeater ID="rptData" runat="server" OnItemDataBound="OnItemDataBound">
<ItemTemplate>
<asp:Literal ID="ltrlSessionEndTime" runat="server" Text='<%# Eval("SessionEndTime","{0: HH:mm}") %>'></asp:Literal>
<asp:Literal ID="ltrlBookTitle" runat="server" Text='<%# Eval("BookTitle") %>'></asp:Literal>
<asp:Image ID="img" runat="server" Width="100" Height="100" />
<asp:HiddenField ID="hfimg" runat="server" Value='<%# Eval("ThumbImage") %>' />
</ItemTemplate>
</asp:Repeater>
Namespaces
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3]
{
new DataColumn("SessionEndTime", typeof(DateTime)),
new DataColumn("BookTitle"),
new DataColumn("ThumbImage")
});
dt.Rows.Add("17-2-2022 01:12", "History", "img/Picture1.png");
rptData.DataSource = dt;
rptData.DataBind();
}
}
protected void OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Image control = e.Item.FindControl("img") as Image;
HiddenField control1 = e.Item.FindControl("hfimg") as HiddenField;
control.ImageUrl = control1.Value;
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim dt As DataTable = New DataTable()
dt.Columns.AddRange(New DataColumn(2) {
New DataColumn("SessionEndTime", GetType(DateTime)),
New DataColumn("BookTitle"),
New DataColumn("ThumbImage")})
dt.Rows.Add("17-2-2022 01:12", "History", "img/Picture1.png")
rptData.DataSource = dt
rptData.DataBind()
End If
End Sub
Protected Sub OnItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
Dim control As Image = TryCast(e.Item.FindControl("img"), Image)
Dim control1 As HiddenField = TryCast(e.Item.FindControl("hfimg"), HiddenField)
control.ImageUrl = control1.Value
End If
End Sub