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
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:
Then go through and assign each TextBox to the appropriate field:
If you have several dozen TextBoxes to assign, you could set up a custom control that can be databound to an
equipmentobject, 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: