Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8085439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:06:58+00:00 2026-06-05T18:06:58+00:00

In my application i m retrive data from database. In database contain 10 records.

  • 0

In my application i m retrive data from database. In database contain 10 records. but when i am display record in page it display only one record. i want all 10 record neeeds to be display. i m using session variable to store and display data in page . i dont want any control to bind data. i want only session variable to be used to store and display data . below i m write code. i know session store only one value but i want session store multiple value and display multiple data.

.cs file

protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection("Data Source=Aarambh;Initial Catalog=rebuild_technology;Integrated Security=True");
        con.Open();
        SqlCommand cmd = new SqlCommand("select * from content_managment ", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        foreach (DataRow dr in ds.Tables[0].Rows)

        {
            Session["divhtml_heading1"] = dr["divhtml_content"].ToString();

        }
}

Here i am display data in aspx page.

Source code

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Home" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <% Response.Write(Session["divhtml_heading1"].ToString()); %>
</asp:Content>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:06:59+00:00Added an answer on June 5, 2026 at 6:06 pm

    I would recommend to store all database contents in Custom object like

    List<string> lstOfDivHtml = new List<string>();
    

    Store contents in it in foreach loop like

     foreach (DataRow dr in ds.Tables[0].Rows)
     {
        lstOfDivHtml.Add(dr["divhtml_content"].ToString());
     }
    

    You populate lstOfDivHtml in the forloop & then set it in session once after the for loop like

    Session["divhtml_heading1"] = lstOfDivHtml 
    

    And when you display the contents on page, retrieve lstofDivHtml from Session & display it in loop

    var list = Session["divhtml_heading1"] as List<string>; // now loop over 'list'.
    

    P.S.

    protected void Page_Load(object sender, EventArgs e)
        {
            //Define list
            List<string> lstOfDivHtml = new List<string>();  
            SqlConnection con = new SqlConnection("Data Source=Aarambh;Initial Catalog=rebuild_technology;Integrated Security=True");
            con.Open();
            SqlCommand cmd = new SqlCommand("select * from content_managment ", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
              //add records from dr to lstOfDivHtml 
              lstOfDivHtml.Add(dr["divhtml_content"].ToString());
            }
      }
    

    On Page markup or codebehind

    <% 
    var list = Session["divhtml_heading1"] as List<string>;
    foreach(var item in  list )
    {
     Response.Write(item); 
    }
    %> 
    

    Cant be more specific than this now 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want applications to share certain database data. I want one application to retrieve
In my web application, I want to retrieve data from database based on the
I am new to iphone development.previously i have retrive the data from database... I
I have a Silverlight application that needs to retrieve some data from my database.
I'm building an application in Java to retrieve data from MySQL database. After executing
In web application [asp.net] shall we write code that can retrive data from datbase
i'm working on an iPhone application which retrieve sqlite database from server through json/rest
I have an application which uses Hibernate for database transactions, I have mapped all
I retrived data from database in form of dynamic list with hyperlink. Now I
I am working with Windows form application. In that I retrieve the data from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.