Hi ramco1917,
Please refer below sample.
HTML
<asp:Repeater ID="rptDetails" runat="server" OnItemDataBound="rptDetails_ItemCommand">
<HeaderTemplate>
<table>
<tr>
<td>Source</td>
<td>InvoiceNumber</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Literal ID="ltrlSource" runat="server" Text='<%# Eval("Source") %>'></asp:Literal></td>
<td>
<asp:Literal ID="ltrlInvoice" runat="server" Text='<%# Eval("InvoiceNumber") %>'></asp:Literal></td>
<td>
<asp:HyperLink ID="lnkAmazon" runat="server" NavigateUrl="www.amazon.in" Text="Amazon"></asp:HyperLink>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
Namesapce
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[2] {
new DataColumn("Source"),
new DataColumn("InvoiceNumber") });
dt.Rows.Add("Amazon", "5325102");
dt.Rows.Add("Other", "0325421");
dt.Rows.Add("Data", "5325102");
dt.Rows.Add("Amazon", "0325421");
rptDetails.DataSource = dt;
rptDetails.DataBind();
}
}
protected void rptDetails_ItemCommand(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
RepeaterItem rptDetails = e.Item;
Literal ltrlInvoice = ((rptDetails.FindControl("ltrlInvoice")) as Literal);
Literal ltrlSource = ((rptDetails.FindControl("ltrlSource")) as Literal);
if (ltrlSource.Text == "Amazon")
{
HyperLink lnkAmazon = (HyperLink)e.Item.FindControl("lnkAmazon") as HyperLink;
lnkAmazon.NavigateUrl = "www.amazon.com";
lnkAmazon.Text = "www.amazon.com";
}
else if (ltrlSource.Text != "Amazon")
{
HyperLink lnkAmazon = (HyperLink)e.Item.FindControl("lnkAmazon") as HyperLink;
lnkAmazon.NavigateUrl = "www.amazon.in";
lnkAmazon.Text = "www.amazon.in";
}
}
}
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(1) {
New DataColumn("Source"),
New DataColumn("InvoiceNumber")})
dt.Rows.Add("Amazon", "5325102")
dt.Rows.Add("Other", "0325421")
dt.Rows.Add("Data", "5325102")
dt.Rows.Add("Amazon", "0325421")
rptDetails.DataSource = dt
rptDetails.DataBind()
End If
End Sub
Protected Sub rptDetails_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
Dim rptDetails As RepeaterItem = e.Item
Dim ltrlInvoice As Literal = (TryCast((rptDetails.FindControl("ltrlInvoice")), Literal))
Dim ltrlSource As Literal = (TryCast((rptDetails.FindControl("ltrlSource")), Literal))
If ltrlSource.Text = "Amazon" Then
Dim lnkAmazon As HyperLink = TryCast(CType(e.Item.FindControl("lnkAmazon"), HyperLink), HyperLink)
lnkAmazon.NavigateUrl = "www.amazon.com"
lnkAmazon.Text = "www.amazon.com"
ElseIf ltrlSource.Text <> "Amazon" Then
Dim lnkAmazon As HyperLink = TryCast(CType(e.Item.FindControl("lnkAmazon"), HyperLink), HyperLink)
lnkAmazon.NavigateUrl = "www.amazon.in"
lnkAmazon.Text = "www.amazon.in"
End If
End If
End Sub
Screenshot