Hi amitsinghr,
I have cross check your code everything working fine.You need to check your pageload event.You are using !IsPostback or not like below.
HTML
<div>
<div class="col-md-6">
<asp:Repeater ID="rptPageList" runat="server">
<HeaderTemplate>
<table class="table table-hover">
<thead>
<tr>
<th>
#
</th>
<th>
Page Name
</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<%-- <asp:CheckBox ID="chkPageIndex" runat="server" Text='<%#Eval("Id") %>' />--%>
<input id="chkBox" type="checkbox" runat="server" value='<%#Eval("Id") %>' />
</td>
<td>
<%#Eval("PageName") %>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody> </table>
</FooterTemplate>
</asp:Repeater>
</div>
</div>
<div class="clearfix">
</div>
<div class="form-group">
<div style="text-align: center; margin: 25px auto">
<asp:Button ID="btnAdd" runat="server" Text="Add User" CssClass="btn btn-success"
OnClick="btnAdd_Click" />
</div>
</div>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.GetData();
}
}
private void GetData()
{
DataTable dt = new DataTable();
dt.Columns.Add("Id");
dt.Columns.Add("PageName");
dt.Rows.Add("1", "Test1");
dt.Rows.Add("2", "Test2");
dt.Rows.Add("3", "Test3");
dt.Rows.Add("4", "Test4");
rptPageList.DataSource = dt;
rptPageList.DataBind();
}
protected void btnAdd_Click(object sender, EventArgs e)
{
foreach (RepeaterItem aItem in rptPageList.Items)
{
HtmlInputCheckBox chkItemId = (HtmlInputCheckBox)aItem.FindControl("chkBox");
if (chkItemId.Checked)
{
// ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "Room Record Hase Been Save Successfully", true);
ScriptManager.RegisterStartupScript(this, this.GetType(), "message", chkItemId.Value.ToString(), false);
}
}
}