Hi sambath,
Refer the below code.
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.modal-body
{
height: 350px;
overflow: hidden;
}
.modal-body:hover
{
overflow-y: auto;
}
.modal-open
{
overflow: scroll;
}
</style>
<script type="text/javascript">
function checkAll(objRef) {
var GridView = objRef.parentNode.parentNode.parentNode;
var inputList = GridView.getElementsByTagName("input");
for (var i = 0; i < inputList.length; i++) {
var row = inputList[i].parentNode.parentNode;
if (inputList[i].type == "checkbox" && objRef != inputList[i]) {
if (objRef.checked) {
inputList[i].checked = true;
}
else {
inputList[i].checked = false;
}
}
}
}
function Check_Click(objRef) {
var row = objRef.parentNode.parentNode;
var GridView = row.parentNode;
var inputList = GridView.getElementsByTagName("input");
for (var i = 0; i < inputList.length; i++) {
var headerCheckBox = inputList[0];
var checked = true;
if (inputList[i].type == "checkbox" && inputList[i] != headerCheckBox) {
if (!inputList[i].checked) {
checked = false;
break;
}
}
}
headerCheckBox.checked = checked;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager runat="server" />
<asp:Panel ID="pnlsms" runat="server" Style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title panel-title" id="ModalTitle">
Select Members</h4>
</div>
<div class="modal-body">
<asp:UpdatePanel ID="upModal" runat="server">
<ContentTemplate>
<center>
<asp:GridView ID="gridsendsms" DataKeyNames="ID" AutoGenerateColumns="False" BorderWidth="5px"
BorderColor="YellowGreen" BorderStyle="Groove" runat="server">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
Select All
<asp:CheckBox ID="cbSelectAll" runat="server" onclick="checkAll(this);" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" onclick="Check_Click(this)" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" />
</asp:TemplateField>
<asp:TemplateField HeaderText="S.No" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<%#Container.DataItemIndex+1 %>
</ItemTemplate>
<ItemStyle Width="32px" />
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="mobile" HeaderText="mobile" />
</Columns>
</asp:GridView>
<br />
<br />
</center>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="modal-footer">
<center>
<asp:Button ID="btnsend" runat="server" CssClass="btn btn-primary" Text="Send" />
<input type="button" class="btn btn-primary" value="Cancel" onclick="window.location = 'SmsAccess.aspx';" />
</center>
</div>
</div>
</div>
</asp:Panel>
<asp:LinkButton ID="BTNDummy" runat="server"></asp:LinkButton>
<ajax:ModalPopupExtender ID="mpesms" runat="server" PopupControlID="pnlsms" TargetControlID="btnDummy"
BackgroundCssClass="modalBackground">
</ajax:ModalPopupExtender>
</div>
</form>
</body>
</html>
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[3] {
new System.Data.DataColumn("Id", typeof(int)),
new System.Data.DataColumn("Name", typeof(string)),
new System.Data.DataColumn("Mobile",typeof(Int64)) });
dt.Rows.Add(1, "John Hammond", 1111111111);
dt.Rows.Add(2, "Mudassar Khan", 2222222222);
dt.Rows.Add(3, "Suzanne Mathews", 3333333333);
dt.Rows.Add(4, "Robert Schidner", 4444444444);
gridsendsms.DataSource = dt;
gridsendsms.DataBind();
mpesms.Show();
}
}
Screenshot