Hi telldurges,
Refer the below sample code.
HTML
<div>
<asp:Label ID="lbl_alloted" Text="0" runat="server" Visible="false"></asp:Label>
<div class="table table-responsive over-auto " id='example'>
<table id="myTable_k" class="table table-striped table-bordered">
<thead>
<tr>
<th>
S.No.
</th>
<th>
<div class="checkbox checkbox-info m-0">
<asp:CheckBox ID="checkeddall" runat="server" />
<label>
Select
</label>
</div>
</th>
<th>
Substitution Pattern
</th>
<th>
Order No.
</th>
</tr>
</thead>
<tbody>
<asp:Repeater ID="rpt_SubsSetting" runat="server">
<ItemTemplate>
<tr id="ItemRow">
<td>
<%# Container.ItemIndex + 1 %>
<asp:Label ID="lblid" runat="server" Text='<%# Eval("Pat_Id") %>' Visible="false" />
</td>
<td>
<div class="checkbox checkbox-info m-0">
<asp:CheckBox ID="chkSelect" onclick="CustomValidation(this)" Checked='<%# Eval("pat_check").ToString() == "True" %>'
runat="server" CssClass="chkbox m-0" Text=" " />
</div>
</td>
<td>
<asp:Label ID="lbl_subjects" runat="server" Text='<%# Eval("Pat_Name") %>' />
</td>
<td>
<div class="col-md-6 p-0">
<asp:HiddenField ID="hdnid" runat="server" />
<asp:TextBox ID="TXT_periods" setcss="input-sm" texttype="Numeric" required="true"
maxvalue="90" runat="server" Enabled="false" setfocus="true" setenable="true"
Text='<%# Eval("Pat_Number") %>' />
</div>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</tbody>
</table>
</div>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
var arr = new Array();
function CustomValidation(ele) {
var txt = $("input[id*='TXT_periods']");
var chk = $("input[id*='chkSelect']");
var checkedIndex = $(ele).closest('tr').index();
if ($(ele).closest('tr').find($("input[id*='chkSelect']")).is(':checked')) {
arr.push(checkedIndex);
}
else {
arr = arr.filter(function (item) {
return item !== checkedIndex
});
}
for (var i = 0; i < arr.length; i++) {
txt[arr[i]].value = i + 1;
txt[arr[i]].disabled = false;
}
for (var i = 0; i < chk.length; i++) {
if (!chk[i].checked) {
txt[i].disabled = true;
txt[i].value = '';
}
}
}
</script>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.AddRange(new System.Data.DataColumn[4] {
new System.Data.DataColumn("Pat_Id", typeof(int)),
new System.Data.DataColumn("pat_check", typeof(bool)),
new System.Data.DataColumn("Pat_Name",typeof(string)),
new System.Data.DataColumn("Pat_Number",typeof(int)) });
dt.Rows.Add(1, false, "John Hammond", 1);
dt.Rows.Add(2, false, "Mudassar Khan", 3);
dt.Rows.Add(3, false, "Suzanne Mathews", 2);
dt.Rows.Add(4, false, "Robert Schidner", 4);
rpt_SubsSetting.DataSource = dt;
rpt_SubsSetting.DataBind();
}
}
Screenshot