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


Top 5 Contributors of the Month
david stephan

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...


Thanks
Selvakumar .K

Responses
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...

.aspx(source)

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick">
</asp:Timer>
<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" />
<Columns>
<asp:TemplateField HeaderText="Customer Name">
<ItemTemplate>
<asp:Label runat="server" ID="lblusername" Text='<%#Eval("uname")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Contacts">
<ItemTemplate>
<asp:Label runat="server" ID="lbllogintime" Text='<%#Eval("contacts")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Waiting Time">
<ItemTemplate>
<asp:Label runat="server" ID="lblwaitingtime" Text='<%#Eval("waitingtime")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:Label ID="lblstatus" runat="server" Text='<%#Eval("status")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Agent Name">
<ItemTemplate>
<asp:Label ID="lblagentname" runat="server" Text='<%#Eval("agentname")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Action">
<ItemTemplate>
<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") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<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" />
</asp:GridView>
</div>
<div class="fm-row">
<label>
&nbsp;</label>
<asp:Label ID="lblmessage" runat="server" Font-Bold="True" Font-Size="Medium" ForeColor="Black"></asp:Label>
<!-- grid -->
</div>
</ContentTemplate>

</asp:UpdatePanel>



Codebehind:-

protected void lnkbtnname0_Click(object sender, EventArgs e)
{
try
{


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>");

fillgrid();

}



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);
SP.UI.ModalDialog.showModalDialog(options);
}
function CloseCallback(result, target) {
location.reload(true);
}

</script>

_________________________________________________________________________


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


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.
http://www.kettic.com/winforms_ui/gridview.shtml



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
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

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