GridView To Another Page GridView Send Values
One Gridview Display Values Send To Another Page Gridview Using DataTable Or DataSet With Pass Session & Get Another Page Page_Load Get Session bind To Gridview In Asp.Net C#.
DEMO
HTML CODING(Second Page)
C# CODING(First Page)
First - Add New Web Form - Insert DataBase Table Values
Next - Add GridView & Button From Toolbox in First Page
Next - Select Database Table Values To Bind GridView & Session Pass DataSet ValuesTo Another Page
Next - Second Page - Add Gridview From Tool Box
Second Page - Page_Load - Get Session Values & Bind To GridView
Next - Run[F5] - Display GridView Values - Click Button - Send DataSet Values To Next Page
One Gridview Display Values Send To Another Page Gridview Using DataTable Or DataSet With Pass Session & Get Another Page Page_Load Get Session bind To Gridview In Asp.Net C#.
DEMO
HTML CODING(First Page)
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table><tr><td></td><td><asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" >
<HeaderStyle BackColor="#FF3300" />
<RowStyle BackColor="Silver" />
<AlternatingRowStyle BackColor="#9999FF" />
</asp:GridView></td></tr>
<tr><td colspan="2"> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Send Next Page" /></td></tr>
</table>
<br />
</div>
</form>
</body>
</html>
HTML CODING(Second Page)
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> </title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table><tr><td> </td><td> <asp:GridView ID="GridView1" runat="server">
<AlternatingRowStyle BackColor="#9999FF" />
<HeaderStyle BackColor="#FF3300" />
<RowStyle BackColor="#FF99FF" />
</asp:GridView>
</td></tr></table>
</div>
</form>
</body>
</html>
C# CODING(First Page)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data;
using System.Data.SqlClient;
public partial class Default4 : System.Web.UI.Page
{
DataSet ds1;
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["dbcon"].ToString());
con.Open();
SqlCommand cmd = new SqlCommand("select * from
country", con);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
ds1 = new DataSet();
adp.Fill(ds1);
GridView1.DataSource = ds1;
GridView1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
Session["ds"] = ds1;
Response.Redirect("Default3.aspx");
}
}
C# CODING(Second Page)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds2 = new DataSet();
ds2 = (DataSet)Session["ds"];
GridView1.DataSource = ds2;
GridView1.DataBind();
}
}
Next - Add GridView & Button From Toolbox in First Page
Next - Select Database Table Values To Bind GridView & Session Pass DataSet ValuesTo Another Page
Next - Second Page - Add Gridview From Tool Box
Second Page - Page_Load - Get Session Values & Bind To GridView
Next - Run[F5] - Display GridView Values - Click Button - Send DataSet Values To Next Page
0 comments:
Post a Comment