HTML
<form id="form1" runat="server">
<div>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="40%">
<%#DataBinder.Eval(Container.DataItem, "CourseName")%>
</td>
<td width="25%">
<%#DataBinder.Eval(Container.DataItem, "CourseDate")%>
</td>
<td width="40%">
<asp:Label ID="lblCourseCode" Text='<%#DataBinder.Eval(Container.DataItem, "CourseCode")%>' runat="server" />
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
<br />
<br />
<br />
<asp:GridView ID="GridView1" runat="server" BorderColor="#999999" BorderStyle="None"
BorderWidth="1px" CellPadding="3" GridLines="Vertical" Height="1px" Width="676px"
Font-Size="Smaller" AutoGenerateSelectButton="true" BackColor="White">
</asp:GridView>
<asp:Button Text="Compare" OnClick="Compare" runat="server" />
</div>
</form>
Namespace
using System.Data;
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("CourseName", typeof(string)),
new DataColumn("CourseDate", typeof(string)),
new DataColumn("CourseCode",typeof(string)) });
DataTable dt2 = new DataTable();
dt2.Columns.AddRange(new DataColumn[3] { new DataColumn("CourseName", typeof(string)),
new DataColumn("CourseDate", typeof(string)),
new DataColumn("CourseCode",typeof(string)) });
dt2.Rows.Add("RAFF", "30 mar 14", "PST0");
dt2.Rows.Add("RPST", "30 mar 14", "PSTF");
dt.Rows.Add("RAFF", "30 mar 14", "PSTF");
dt.Rows.Add("RPST", "30 mar 14", "PST0");
dt.Rows.Add("MFA", "29 mar 14", "AMC");
this.Repeater1.DataSource = dt2;
this.Repeater1.DataBind();
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
}
}
protected void Compare(object sender, EventArgs e)
{
string gridValue = this.GridView1.Rows[2].Cells[2].Text;
string repeaterValue = (this.Repeater1.Items[1].FindControl("lblCourseCode") as Label).Text;
if (gridValue == repeaterValue)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Same Value')", true);
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Different Value')", true);
}
}