.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Popup issue in gridview

Posted By: Selva Mca     Posted Date: November 26, 2013    Points:5   Category :ASP.Net
Hi All,
I am working on a project (Asp.net-C#), in that a page contain Gridview, inside the gridview i kept a linkbutton for pop up. its working nice, but i need gridiview auto refresh, if gridview get auto refresh pop up should n't come, without autorefresh popup working properly, i want gridview get refresh also popup will work, help me out friends...

Selvakumar .K

Author: volvo             
Posted Date: November 26, 2013     Points: 20   

Hi Selva,
If i am not wrong , you are trying to open a popup on click of a link button in gridview.you are doing some activity in popup and saving it.After saving your pop up get closed and your parent pagedoesn't get refreshed.If the problem is same the at first share your scipt you are using to open popup.

Author: Selva Mca             
Posted Date: November 27, 2013     Points: 20   

Hi spasin,
Thanks for your kind reply, here i paste my code kindly look at it and give me some better solution,
in the following code i did use updatepanel for autorefresh with timer, then popup code written in linkbutton click event...


<asp:ScriptManager ID="ScriptManager1" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick">
<div class="grid">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging"
OnSelectedIndexChanged="GridView1_SelectedIndexChanged" PageSize="20" AutoGenerateColumns="False"
OnRowDataBound="GridView1_RowDataBound" CellPadding="4" ForeColor="#333333" GridLines="None"
CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<asp:TemplateField HeaderText="Customer Name">
<asp:Label runat="server" ID="lblusername" Text='<%#Eval("uname")%>'></asp:Label>
<asp:TemplateField HeaderText="Contacts">
<asp:Label runat="server" ID="lbllogintime" Text='<%#Eval("contacts")%>'></asp:Label>
<asp:TemplateField HeaderText="Waiting Time">
<asp:Label runat="server" ID="lblwaitingtime" Text='<%#Eval("waitingtime")%>'></asp:Label>
<asp:TemplateField HeaderText="Status">
<asp:Label ID="lblstatus" runat="server" Text='<%#Eval("status")%>'></asp:Label>
<asp:TemplateField HeaderText="Agent Name">
<asp:Label ID="lblagentname" runat="server" Text='<%#Eval("agentname")%>'></asp:Label>
<asp:TemplateField HeaderText="Action">
<asp:LinkButton ID="lnkbtnname0" runat="server" Visible='<%# Eval("status").ToString() == "Waiting" %>'
OnClick="lnkbtnname0_Click" Value='<%#Eval("uname")%>'>Accept</asp:LinkButton>
<asp:LinkButton ID="lnkbtnname2" runat="server" Visible='<%# Eval("status").ToString() == "Waiting" %>'
Text="Reject" OnClick="lnkbtnname2_Click">Reject</asp:LinkButton>
<asp:LinkButton ID="lnkbtnname1" runat="server" Visible='<%# Eval("status").ToString() == "Chatting" %>'
Text="Stop" OnClick="lnkbtnname1_Click">Stop</asp:LinkButton>
<asp:HiddenField ID="hidtoken" runat="server" Value='<%#Eval("token") %>' />
<asp:HiddenField ID="hidcustid" runat="server" Value='<%#Eval("slno") %>' />
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
<div class="fm-row">
<asp:Label ID="lblmessage" runat="server" Font-Bold="True" Font-Size="Medium" ForeColor="Black"></asp:Label>
<!-- grid -->



protected void lnkbtnname0_Click(object sender, EventArgs e)

LinkButton lb = (LinkButton)sender;
GridViewRow row = (GridViewRow)lb.NamingContainer;
if (row != null)
index = row.RowIndex; //gets the row index selected
HiddenField lnk = GridView1.Rows[index].FindControl("hidtoken") as HiddenField;
token = lnk.Value.ToString();
lnk = GridView1.Rows[index].FindControl("hidcustid") as HiddenField;
custid = Convert.ToInt32(lnk.Value);
Session["idcustomer"] = custid;

agentid = Session["userid"].ToString();
DataAccessHelper.DataAccessHelper.SqlHelper.ExecuteDataset(mconstring, "SpUpdateAgentStatus", agentid);
DataAccessHelper.DataAccessHelper.SqlHelper.ExecuteDataset(mconstring, "SpUpdateCustomerStatus", custid, agentid);
Label lbl = GridView1.Rows[index].FindControl("lblagentname") as Label; LinkButton lnbtn = GridView1.Rows[index].FindControl("lnkbtnname0") as LinkButton;
LinkButton lnbtn1 = GridView1.Rows[index].FindControl("lnkbtnname1") as LinkButton;

string messgae = "Agent Joined Just now"; string msgtype = "3";
DataAccessHelper.DataAccessHelper.SqlHelper.ExecuteDataset(mconstring, "SpstoreChatmsg", custid, agentid, messgae, msgtype, token);

//Response.Write("<script>window.open('chat.aspx?token=" + token + "&customerid=" + custid + "&agentid=" + agentid + " ','', 'copyhistory=no, width=452, height=510, top=100, left=100, resizable=0, menubar=0, toolbar=0, titlebar=0, statusbar=0, scrollbars=1');</script>");
pop = 1;
Response.Write("<script>window.open('chat.aspx?token=" + token + "&customerid=" + custid + "&agentid=" + agentid + " ','', 'copyhistory=no, width=452, height=510, top=100, left=100, resizable=0, menubar=0, toolbar=0, titlebar=0, statusbar=0, scrollbars=1');</script>");



catch (Exception ex) { }

Author: volvo          Accepted Answer   
Posted Date: November 27, 2013     Points: 40   

Hi, Thanks for sharing code.

you can solve your issue as below script

<script language="javascript" type="text/javascript">

function OpenPopUp(ID) {
var sLoc = window.location.toString();
var options = SP.UI.$create_DialogOptions();

options.url = 'yoururl?LeaveID=' + ID;
options.autosize = true;
options.width = "750";
options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);
function CloseCallback(result, target) {



<asp:LinkButton ID="btnEdit" runat="server" Text="Edit" OnClientClick='<%# Eval("ID", "javascript:OpenPopUp(\"{0}\"); return false;") %>'
CssClass="space" />

you may need to add reference of Jquesry.

Author: Selva Mca             
Posted Date: December 02, 2013     Points: 20   

Hi spasin,
Thanks i have done.

Author: Clintonzz             
Posted Date: December 03, 2013     Points: 20   

There is a tutorial for all the use of Gridview control.
I hope it be useful to you.

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend