Hi sonasri,
I have created a sample which full fill your requirement you need to modify the code according to your need.
HTML
<div>
Dynamic CheckBoxes:-<br />
<asp:PlaceHolder ID="PlcHldrSeatDetails" runat="server"></asp:PlaceHolder>
<br />
<div id="divDisplay" style="display: none;">
This Div Gets Displayed When one of the Dynamic CheckBox is Checked.
<br />
Checked CheckBoxes Values =
<asp:Label ID="lblValues" Font-Bold="true" runat="server" />
</div>
</div>
<div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
var values = [];
$('.dynamic').click(function () {
$('[id*=divDisplay]').attr('style', 'display:block');
if ($(this).find('input').is(":checked")) {
values.push($(this)[0].innerText);
}
else {
removevalue = $(this)[0].innerText;
values = jQuery.grep(values, function (value) {
return value != removevalue;
});
}
$('[id*=lblValues]').html(values.join(','));
});
});
</script>
</div>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
for (int i = 1; i <= 5; i++)
{
CheckBox dynamicCheckBox = new CheckBox();
dynamicCheckBox.ID = "dynamicCheckBox" + i;
dynamicCheckBox.Attributes["class"] = "dynamic";
dynamicCheckBox.Text = i.ToString();
Literal lt = new Literal();
lt.Text = "<br />";
PlcHldrSeatDetails.Controls.Add(dynamicCheckBox);
PlcHldrSeatDetails.Controls.Add(lt);
}
}
}
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
For i As Integer = 1 To 5
Dim dynamicCheckBox As New CheckBox()
dynamicCheckBox.ID = "dynamicCheckBox" + i.ToString
dynamicCheckBox.Attributes("class") = "dynamic"
dynamicCheckBox.Text = i.ToString()
Dim lt As New Literal()
lt.Text = "<br />"
PlcHldrSeatDetails.Controls.Add(dynamicCheckBox)
PlcHldrSeatDetails.Controls.Add(lt)
Next
End If
End Sub
ScreenShot