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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:34:10+00:00 2026-05-15T19:34:10+00:00

So I haven’t used ASP.NET for three years or so and I’m really rusty

  • 0

So I haven’t used ASP.NET for three years or so and I’m really rusty on it. My old code isn’t available to me for review (at an old company). This question should be pretty basic, but I can’t find any good or reliable or not-super-old resources on the issue, so I’m asking here.

Can I get a general overview of databinding again? I remember it being really useful for select boxes, etc., but I don’t really remember how it works. Maybe a good ASP.NET tutorial in general, because I don’t remember how it handles POST requests or anything like that really either. Should I just try ASP.NET MVC?

Relatedly, suppose I have a public variable in my codebehind page. Right now I am accessing it by saying Page.DataBind() at the end of the page load function and then running <%# variable %> in the ASPX, but that’s not how I remember doing it before and I reckon that it’s not very good practice. What’s the best way to display variables from codebehind?

  • 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-15T19:34:10+00:00Added an answer on May 15, 2026 at 7:34 pm

    Databinding in general (at least in the WebForms model) is mostly a case of assigning fields to be displayed, setting the DataSource property to a suitable object that contains those fields e.g. a DataReader, DataTable, a Collection, and calling the DataBind method. So for your select case, you’d put an <asp:dropdownlist runat="server" id="MyDropDownList"> in the markup for the page, and then in the code

    DataSet myDataSet;
    
    myDataSet = someDataMethod();
    
    MyDropDownList.DataTextField = fieldname;
    MyDropDownList.DataValueField = fieldname;
    MyDropDownList.DataSource = myDataSet;
    MyDropDownList.DataBind();
    

    Or you can avoid writing that kind of code and do it in the markup if you use a DataSource control e.g. <asp:SqlDataSource>, <asp:ObjectDataSource>

    <asp:SqlDataSource runat="server" id="MySqlDataSource" ConnectionString="aConnectionString" SelectCommand="MyStoredProcName" SelectCommandType="StoredProcedure"  />
    <asp:dropdownlist runat="server" id="MyDropDownList" DataSourceId="MySqlDataSource" DataTextField="fieldname" DataValueField="fieldname">
    

    For putting your variable on a page, the way you might have done it before is to have a label or textbox on the page, that in your code-behind you assign your variable to the Text property e.g.

    <asp:label runat="server" id="MyLabel" />
    
    MyLabel.Text = myVariable.ToString();
    

    Postbacks: you can test the IsPostback property of a page in code-behind to determine if it’s a postback or not. After the Page_Load method, other methods will fire if you’ve defined them e.g. SelectedIndexChanged for a DropDownList.

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

Sidebar

Related Questions

Haven't done ASP.NET development since VS 2003, so I'd like to save some time
I haven't used the STL much before, but I started to on this huffman
I haven't used ARC yet other than to deal with it when it forces
I haven't used multithreading in Clojure at all so am unsure where to start.
I haven't been able to get this working and all of the sample code
I haven't designed a website for about 3 years now, so I am quite
Haven't touch javascript for 3 years. Just got a javascript project and wanted to
haven't used regex replaces much and am not sure if how I have done
Haven't touched Ruby for ages so this really puzzled me. Started up irb. Then
I haven't programmed in a few years and I'm creating a small quiz to

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.