.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

How to refresh data on the previous page

Posted By: Mahesh     Posted Date: March 15, 2011    Points:5   Category :ASP.Net
i am having two web pages first page is having data in grid, on cell click of grid other related data is displayed in edit mode on second page when that data is saved now on first page, i wants to refresh data on first page as soon as data is saved on second page, both forms are opened they are not closed..how this can be done...thanks in advance

Responses
Author: kamlesh             
Posted Date: March 16, 2011     Points: 20   

You can call the GridView's DataBind method to refresh the grid. or check the below link

http://forums.asp.net/t/1035320.aspx/1?Refresh+Gridview+after+insert+

Thanks And Regards.
Kamlesh Nikam
Author: Mahesh             
Posted Date: March 16, 2011     Points: 20   

Thanks kamlesh for replay, but what i want to do is refresh the grid data on first page when data is saved on second page.

Author: Maverick             
Posted Date: March 16, 2011     Points: 20   

Hello,

You can redirect from first page after saving the data on second page

Thanks,
Maverick

Thanks,
Maverick
Author: Mahesh             
Posted Date: March 17, 2011     Points: 20   

Thanks Maverick, this is what i wants to achive(i.e. fire button click event of previous page from page which was opened) i had attached the code here

First page code

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function ClientCode()
{
document.getElementById('btnProcess').click();
}
</script>
</head>
<body >
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>

<asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>
<input type="hidden" id="hid1" name="hid1" value="" onpropertychange="ClientCode()" />
<asp:Button runat="server" style="display:none;" id="btnProcess" ></asp:Button>
</div>
</form>

</body>
</html>


VB code

Imports System.Data

Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim dt As New DataTable
dt.Columns.Add("t1")
dt.Columns.Add("t2")
dt.Columns.Add("t3")

Dim dr As DataRow = dt.NewRow
dr.Item("t1") = "1"
dr.Item("t2") = "2"
dr.Item("t3") = "3"

dt.Rows.Add(dr)

dr = dt.NewRow
dr.Item("t1") = "1"
dr.Item("t2") = "2"
dr.Item("t3") = "3"

dt.Rows.Add(dr)


GridView1.DataSource = dt
GridView1.DataBind()
LinkButton1.Attributes.Add("onclick", "window.open('Default2.aspx')")
End If

End Sub

Private Sub PopulateData()
Dim dt As New DataTable
dt.Columns.Add("t1")
dt.Columns.Add("t2")
dt.Columns.Add("t3")

Dim dr As DataRow = dt.NewRow
dr.Item("t1") = "1"
dr.Item("t2") = "2"
dr.Item("t3") = "3"

dt.Rows.Add(dr)

dr = dt.NewRow
dr.Item("t1") = "4"
dr.Item("t2") = "5"
dr.Item("t3") = "6"

dt.Rows.Add(dr)


GridView1.DataSource = dt
GridView1.DataBind()
End Sub

Protected Sub btnProcess_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnProcess.Click
PopulateData()
End Sub
End Class

Second page

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function AssignValue()
{
if (window.opener.document.getElementById('hid1').value != "1");
{
window.opener.document.getElementById('hid1').value = "1";
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
</body>
</html>

VB code
Partial Class Default2
Inherits System.Web.UI.Page


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Button1.Attributes.Add("onclick", "AssignValue()")
End Sub
End Class

Author: Aamir Shahzad             
Posted Date: March 17, 2011     Points: 20   

you can use blow links

http://forums.asp.net/t/1035320.aspx/1?Refresh+Gridview+after+insert+

thanks Regards



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