Hi rakeshkuma,
You need to reopen the modal popup if not valid.
Check this example. Now please take its reference and correct your code.
HTML
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Panel ID="pnlAddUpdateitemDetails" runat="server" CssClass="modalPopup" Style="">
<div style="">
<div class="modal-header">
<asp:Label ID="lblHeading" runat="server" CssClass="modal-title"></asp:Label>
</div>
<div class="modal-body">
<div class="row">
<div class="table-responsive" style="">
<div class="" style="">
<asp:GridView ID="gw_requistion_ref" runat="server" CssClass="table table-bordered table-striped" Style="" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="#" HeaderStyle-HorizontalAlign="Left" HeaderStyle-Font-Bold="true" ItemStyle-HorizontalAlign="Left">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="checkAll" runat="server" Checked="true" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Checked="true" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="item" HeaderText="item" Visible="false" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="reqno" HeaderText="Request No" HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Left">
<ItemStyle HorizontalAlign="right" />
</asp:BoundField>
<asp:BoundField DataField="ddta" DataFormatString="{0:dd-MM-yyyy}" HeaderText="Delivery Date" HeaderStyle-Font-Bold="true" HeaderStyle-HorizontalAlign="Left" />
</Columns>
</asp:GridView>
</div>
</div>
<asp:Label runat="server" ForeColor="Red" Font-Size="12px" ID="lblerroroncheck"></asp:Label>
</div>
<div class="modal-footer">
<div class="row">
<asp:Button ID="btnselect" runat="server" Text="IMPORT" CssClass="btn btn-primary btn-xs"
OnClientClick="return validateCheckBoxes()" />
<asp:Button ID="btnCancel" runat="server" Text="CLOSE" CssClass="btn btn-primary btn-xs" />
</div>
</div>
</div>
</div>
</asp:Panel>
<ajax:ModalPopupExtender ID="mpeAddUpdateitem" runat="server" PopupControlID="pnlAddUpdateitemDetails"
TargetControlID="LinkButton4" BehaviorID="mpeAddUpdateitem" CancelControlID="btnCancel"
BackgroundCssClass="modalBackground">
</ajax:ModalPopupExtender>
<asp:LinkButton ID="LinkButton4" runat="server">Open Modal</asp:LinkButton>
<script type="text/javascript">
function validateCheckBoxes() {
document.getElementById("lblerroroncheck").innerText = "";
var isValid = true;
var gridView = document.getElementById('<%= gw_requistion_ref.ClientID %>');
for (var i = 1; i < gridView.rows.length; i++) {
var inputs = gridView.rows[i].getElementsByTagName('input');
if (inputs != null) {
if (inputs[0].type == "checkbox") {
if (!inputs[0].checked) {
isValid = false;
} else {
isValid = true;
break;
}
}
}
}
if (!isValid) {
document.getElementById("lblerroroncheck").innerText = "Check atleast one check box";
$find('mpeAddUpdateitem').show();
}
return isValid;
}
</script>
Code
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("item"),
new System.Data.DataColumn("reqno"),
new System.Data.DataColumn("ddta",typeof(DateTime)) });
dt.Rows.Add("Item 1", "123", "12/28/2020");
dt.Rows.Add("Item 2", "456", "12/28/2020");
dt.Rows.Add("Item 3", "789", "12/28/2020");
gw_requistion_ref.DataSource = dt;
gw_requistion_ref.DataBind();
}
}
Screenshot