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

  • Home
  • SEARCH
  • 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 6619979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:02:28+00:00 2026-05-25T21:02:28+00:00

I am trying o set textboxes on an ASP.NET webpage using LINQ – SQL.

  • 0

I am trying o set textboxes on an ASP.NET webpage using LINQ – SQL. Here is the code I have to perform the select statement:

    EQCN = Request.QueryString["EQCN"];
    var equipment = from n in db.equipments
                    where n.EQCN.ToString() == EQCN
                    select n;

How do I set TextBox1.text to be a specific field in the table?

Thanks so much

EDIT

I need to output every field in the table into different textboxes. So performing a query for ever single one seems a little much. There has to be a way to do this?

Thanks

  • 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-25T21:02:29+00:00Added an answer on May 25, 2026 at 9:02 pm

    You only need to perform the query once, but once that’s done, you’ll have to assign each field to a TextBox. Start by retrieving only the single item you want:

    EQCN = Request.QueryString["EQCN"];
    var equipment = (from n in db.equipments
                     where n.EQCN.ToString() == EQCN
                     select n).FirstOrDefault();
    

    Then go through and assign each TextBox to the appropriate field:

    txtName.Text = equipment.Name;
    txtDescription.Text = equipment.Description;
    txtValue1.Text = equipment.Value1;
    txtValue2.Text = equipment.Value2;
    //...
    

    If you have several dozen TextBoxes to assign, you could set up a custom control that can be databound to an equipment object, but even then, you’ll still have to write the binding code for your control.

    The only way I can think of to totally automate this process is to name each TextBox after a field in your object, then use reflection to match them to values:

        var textboxes = Panel1.Controls.OfType<TextBox>();
    
        foreach (TextBox txt in textboxes)
        {
            string fieldname = txt.ID.Remove(0, 3); //"txtDescription" becomes "Description"
    
            string value = equipment.GetType().GetProperty(fieldname).GetValue(equipment, null) as string;
            txt.Text = value;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using asp.net mvc 2.0(default binding model) and I have this problem. I
I'm trying to do something that sounds fairly simple using ASP.NET 3.5. A user
I'm trying to set new value for asp.net control property when I check a
I'm trying to create a ASP.NET MVC 2 webapp using the Northwind database following
I am trying to set the style of an asp:TextBox in codebehind, the textbox
Trying to set up caching on our datasets - we're using clr stored procedures
I am a newbie to ASP.NET MVC (v2), and I am trying to use
ASP.NET MVC Model Binding is still new to me and I'm trying to understand
i m trying to edit the values in database through textboxes in ASP. first
So, let's say I have this code (VB.Net): Sub Main() dim xxx as string

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.