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 6783933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:55:49+00:00 2026-05-26T16:55:49+00:00

I am developing a web template with ASP.NET using C#. My connection string is:

  • 0

I am developing a web template with ASP.NET using C#. My connection string is:

<connectionStrings>
<add name="NorthwindConnectionString" 
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SecurityTutorials.mdf;Integrated Security=True;User Instance=True" 
providerName="System.Data.SqlClient"/>
</connectionStrings>

and the access of the connection string is as below:

string connStr = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;

my SqlDataSource is as follows:

 <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
 ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
 SelectCommand="SELECT [ProductID], [ProductName], [Discontinued] FROM [Alphabetical list of products]"
 InsertCommand = "INSERT INTO [Alphabetical list of products] (ProductID, ProductName, Discontinued)VALUES(@ProductID,@ProductName,@Discontinued)">
<InsertParameters>
<asp:Parameter Name="ProductID" Type="String" />
<asp:Parameter Name="ProductName" Type="String" />
<asp:Parameter Name="Discontinued" Type="String" />
</InsertParameters> 
</asp:SqlDataSource>

I have put a ListView on the page to display the data. Now how can I access the data in the database and how can I retrieve the data and show it inside the page using code behind?

As you know by using <%# Eval("ProductName") %> inside the page all data are accessible.
For example, I have a column ProductName, I want to get the data in this column, do some reformatting and pass it to the page form code behind, and also write the SqlDataSource at the code behind.

  • 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-05-26T16:55:50+00:00Added an answer on May 26, 2026 at 4:55 pm

    I bet there are more options than this one, but this is how I would’ve done it. Cut out the SqlDataSource in the page and fetch and bind the data from the code:

    using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString)
    {
      var selectCommand = new SqlCommand("SELECT ...");
    selectCommand.CommandType = CommandType.Text; selectCommand.Connection = connection;

      var dataAdapter = new SqlDataAdapter()
      dataAdapter.SelectCommand = selectCommand

      var dataSet = new DataSet();

      connection.Open()
      dataAdapter.Fill(dataSet, "myDataSet");
      connection.Close()

      // now, the dataSet.Tables[0] is a DataTable with your data in it. You can add, edit or remove data in this table before binding it to the ListView

      myListView.DataSource = dataSet;
      myListView.DataBind(); }

    In this example, you’ll have to write separate code for insertion of data. If dealing with ASP.NET, I write my code like this on purpose, since ASP.NET applications are stateless and thus don’t remember any state or data (other than what’s stored in Session or ViewState)

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

Sidebar

Related Questions

The background I'm developing a REST API for a C#.NET web application using WCF.
I'm developing web app that user can save his/her work to server. The data
I'm getting started in developing web services using JAX-WS. I'm trying to implement classes
currently, I am developing web-apps using Eclipse. The build is done using Maven. The
I have 5 years of work experience in developing WEB and WIN application using
I get the session MaxInactiveInterval time using the following query. I am developing web
I'm using .NET 3.5 and WCF for developing a server-client application. Binding=BasicHttp. I'm working
I am developing a web app using the Joomla Framework. The jQuery UI accordion
I am developing an application in C# ASP.NET to allow users to customise a
I am developing web app using Scala and Lift framework. I have record in

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.