Entire column of database store in session

May 2 2016 6:17 AM
 
This is my code 
 
 
 
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class ForStudent : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["cn"]);
SqlDataReader rdr;
DataTable dt;
SqlCommand cmd = new SqlCommand();
DataTable Results = new DataTable();
public static int i = 0;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string final= "select a.Stud_Name,b.Stu_PRN,b.Exam_Year,b.Semister_ID,b.Subject_ID,c.Sub_Name,b.Result,b.Status from Student_Master a join Result_Master b on a.Stud_PRN = b.Stu_PRN join Subject_Master c on c.Sub_ID = b.Subject_ID where b.Stu_PRN='" + TextBox1.Text +"' ";
SqlCommand cmd = new SqlCommand(final,con);
con.Open();
SqlDataReader ids = cmd.ExecuteReader();
//SqlDataAdapter sda = new SqlDataAdapter();
//cmd.Connection = con;
//sda.SelectCommand = cmd;
while (ids.Read())
{
Session["Name"] = ids.GetString(0);
Session["PRN"] = ids.GetValue(1);
Session["Year"] = ids.GetValue(2);
Session["Semister"] = ids.GetValue(3);
//Session["Sub_ID" + i] = ids.GetValue(4);
//Session["Sub_Name"] = ids.GetString(5);
//Session["Result"] = ids.GetValue(6);
//Session["Status"] = ids.GetString(7);
Response.Redirect("FinalResult.aspx");
}
}
}
 
 
I want to store entire column of  Sub_ID,Sub_Name,Result and status in session
 
after storing this the display it in the single gridview on another web page
 
 
is it possible 

Answers (3)