Hi ashish007,
After each post back you need to reopen the modal and make sure you have added the modal to the form.
Refer the updated code.
HTML
<asp:Label ID="Label1" runat="server" />
<div id="dialog" align="center" style="display: none">
<table width="100%">
<tr>
<td>
<asp:Label ID="lblcustom" runat="server" Text="Custom" Font-Names="Verdana" Font-Size="10pt"></asp:Label>
</td>
<td>
<asp:RadioButton ID="rbcustom" runat="server" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:GridView ID="grdview" runat="server" AutoGenerateColumns="false" Width="100%">
<Columns>
<asp:TemplateField ItemStyle-HorizontalAlign="Center">
<HeaderTemplate>
<asp:CheckBox ID="chkSelectAll" runat="server" OnCheckedChanged="chkSelectAll_CheckedChanged" AutoPostBack="true" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkDelete" runat="server" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:TemplateField>
<asp:TemplateField HeaderText="User Id" InsertVisible="False" Visible="False">
<ItemTemplate>
<asp:Label ID="lblUserId" runat="server" Text='<%# Eval("Id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="FirstName" HeaderStyle-CssClass="headertext" ItemStyle-CssClass="name">
<ItemTemplate>
<asp:Label ID="LbFirstName" runat="server" Text='<%# Eval("First_Name") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle />
<ItemStyle />
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="btnupdate" runat="server" Text="Update" CssClass="btnpost"
OnClick="btnupdate_Click" />
</td>
</tr>
</table>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>
<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/blitzer/jquery-ui.css"
rel="stylesheet" type="text/css" />
<script type="text/javascript">
$(function () {
$("#btnShow").click(function () {
ShowPopup();
});
});
function ShowPopup() {
$("#dialog").dialog({
title: "jQuery Dialog",
modal: true
});
$("#dialog").parent().appendTo($("form:first"));
};
</script>
<input type="button" id="btnShow" value="Show Popup" />
Code
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.BindGrid();
}
}
protected void btnupdate_Click(object sender, EventArgs e)
{
try
{
for (int i = 0; i < grdview.Rows.Count; i++)
{
CheckBox CHKDEL = (CheckBox)grdview.Rows[i].FindControl("chkDelete");
if (CHKDEL.Checked)
{
int id1 = (Convert.ToInt32(((Label)(grdview.Rows[i].FindControl("lblUserId"))).Text));
IP.updateuserstoryrights(id1, Int32.Parse(Session["uid"].ToString()));
// upinfo.updateuser(id1);
//Showalluser();
//btnupdate.Visible = false;
}
else
{
Label1.Visible = true;
Label1.Text = "Select Box";
}
}
}
catch (Exception EX)
{
Label1.Visible = true;
Label1.Text = EX.Message;
Label1.ForeColor = System.Drawing.Color.Red;
}
ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowPopup();", true);
}
protected void chkSelectAll_CheckedChanged(object sender, EventArgs e)
{
try
{
CheckBox chkSelectAll = (CheckBox)grdview.HeaderRow.FindControl("chkSelectAll");
for (int i = 0; i < grdview.Rows.Count; i++)
{
CheckBox chkDelete = (CheckBox)grdview.Rows[i].FindControl("chkDelete");
switch (chkSelectAll.Checked)
{
case true:
chkDelete.Checked = true;
break;
case false:
chkDelete.Checked = false;
break;
}
}
}
catch (Exception ex)
{
Label1.Visible = true;
Label1.Text = ex.Message;
Label1.ForeColor = System.Drawing.Color.Red;
}
ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowPopup();", true);
}
protected void BindGrid()
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id"), new DataColumn("First_Name") });
dt.Rows.Add(1, "John Hammond");
dt.Rows.Add(2, "Mudassar Khan");
dt.Rows.Add(3, "Suzanne Mathews");
dt.Rows.Add(4, "Robert Schidner");
grdview.DataSource = dt;
grdview.DataBind();
}