Hi telldurges,
Please refer below sample.
HTML
<asp:Repeater ID="rptValidate" runat="server">
<HeaderTemplate>
<table cellspacing="0" rules="all" border="1">
<tr>
<th>
Class
</th>
<th>
Section
</th>
<th>
PerWeek
</th>
<th>
Period
</th>
<th>
Recess
</th>
<th>
ClassWing
</th>
<th>
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label ID="lblClass" runat="server" Text='<%#Eval("Class") %>'></asp:Label>
</td>
<td>
<asp:Label ID="lblSection" runat="server" Text='<%#Eval("Section") %>'></asp:Label>
</td>
<td>
<asp:TextBox ID="txtCountry" runat="server" Text='<%# Eval("WorkingDaysPerWeek") %>' />
</td>
<td>
<asp:TextBox ID="txtPerDay" runat="server" Text='<%# Eval("PerDay") %>' />
</td>
<td>
<asp:TextBox ID="txtPeriodPerWeek" runat="server" Text='<%# Eval("ProcessAfterPeriodPerWeek") %>' />
</td>
<td>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("ClassWing") %>'></asp:Label>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
<asp:Button ID="btnUpdate" runat="server" Text="Update" OnClick="Update" />
Namespaces
C#
using 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("Class", typeof(string)),
new DataColumn("Section", typeof(string)),
new DataColumn("WorkingDaysPerWeek", typeof(int)),
new DataColumn("PerDay", typeof(int)),
new DataColumn("ProcessAfterPeriodPerWeek", typeof(int)),
new DataColumn("ClassWing", typeof(string)) });
dt.Rows.Add("LKG", "COM-D", 6, 5, "6", "Primary");
dt.Rows.Add("LKG", "COM-E", 6, 8, "6", "Primary");
dt.Rows.Add("LKG", "COM-F", 6, 8, "6", "Primary");
dt.Rows.Add("LKG", "COM-B", 6, 8, "6", "Primary");
dt.Rows.Add("LKG", "COM-C", 6, 8, "6", "Primary");
this.rptValidate.DataSource = dt;
this.rptValidate.DataBind();
}
}
protected void Update(object sender, EventArgs e)
{
TextBox txtPerDay = null;
TextBox txtPerWeek = null;
int i = 0;
foreach (RepeaterItem item in rptValidate.Items)
{
txtPerDay = item.FindControl("txtPerDay") as TextBox;
txtPerWeek = item.FindControl("txtPeriodPerWeek") as TextBox;
int perday = Convert.ToInt32(txtPerDay.Text);
int perweek = Convert.ToInt32(txtPerWeek.Text);
if (perweek > perday)
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('For row number" + (i + 1) + " recess period must be less than period')", true);
}
i++;
}
}
Screenshot