Hi ramco1917,
Please refer below sample.
HTML
<asp:Repeater ID="rptData" runat="server" OnItemDataBound="rptData_ItemDataBound">
<HeaderTemplate>
<table>
<tr>
<td></td>
<td>LeadNumber</td>
<td>StudentName</td>
<td>BookTitle</td>
<td></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:Literal ID="ltrlNum" Text="<%# Convert.ToString(Container.ItemIndex + 1) %>" runat="server"></asp:Literal></td>
<td><asp:Literal ID="ltrlLeadNumber" runat="server" Text='<%# Eval("LeadNumber") %>'></asp:Literal></td>
<td><asp:Literal ID="ltrlChildName" runat="server" Text='<%# Eval("StudentName") %>'></asp:Literal></td>
<td><asp:Literal ID="ltrlBookTitle" runat="server" Text='<%# Eval("BookTitle") %>'></asp:Literal></td>
<td class="text-center">
<asp:LinkButton ID="lnkUpdateStatus" class="text-primary-600" runat="server">Update Status</asp:LinkButton></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
Namespace
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[] {
new DataColumn("LeadNumber"),
new DataColumn("StudentName"),
new DataColumn("BookTitle"),
new DataColumn("Status")});
dt.Rows.Add("1546218144", "Romero", "Cover", "Returned");
dt.Rows.Add("8468942567", "WolaZaja", "TitlePage", "Good");
dt.Rows.Add("2310598408", "Jaime", "DedicationPage", "Lost");
dt.Rows.Add("9801233658", "Owner", "Glossary", "Ok");
rptData.DataSource = dt;
rptData.DataBind();
}
}
protected void rptData_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if ((e.Item.DataItem as DataRowView)["Status"].ToString().ToUpper() == "RETURNED" ||
(e.Item.DataItem as DataRowView)["Status"].ToString().ToUpper() == "LOST")
{
(e.Item.FindControl("lnkUpdateStatus") as LinkButton).Enabled = false;
}
}
}
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() {New DataColumn("LeadNumber"), New DataColumn("StudentName"), New DataColumn("BookTitle"), New DataColumn("Status")})
dt.Rows.Add("1546218144", "Romero", "Cover", "Returned")
dt.Rows.Add("8468942567", "WolaZaja", "TitlePage", "Good")
dt.Rows.Add("2310598408", "Jaime", "DedicationPage", "Lost")
dt.Rows.Add("9801233658", "Owner", "Glossary", "Ok")
rptData.DataSource = dt
rptData.DataBind()
End If
End Sub
Protected Sub rptData_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
If TryCast(e.Item.DataItem, DataRowView)("Status").ToString().ToUpper() = "RETURNED" OrElse
TryCast(e.Item.DataItem, DataRowView)("Status").ToString().ToUpper() = "LOST" Then
TryCast(e.Item.FindControl("lnkUpdateStatus"), LinkButton).Enabled = False
End If
End If
End Sub
Screenshot