0

I am confused about something really simple in ASP.NET. I have seen many times a pattern where there is a three column table, with label, control and validator in each column, which I can put together pretty straightforwardly. However, what I don't understand is how to handle binding here. If I have a table with Customer record and FirstName, LastName and PhoneNum, I want a page that takes customerId in the query string, and binds that record to the page so that I can use Bind() as the text box values.

However, there is no DataSource property on the page to bind the record to. I know I am missing something obvious, but I can't figure it out.

Any help would be appreciated.

2 Answers 2

3

You need to put your controls (labels, textboxes, validators) inside a control that accepts data binding (ie. FormView, GridView, Repeater, etc.etc.) and then bind your data to that control.

Sign up to request clarification or add additional context in comments.

Comments

0

One way to do this is to use a DataSource Control such as a SqlDataSource and use it in conjunction with a Data Control that will bind to the previous datasource control like a DetailsView. Then you configure your DataSource control to only bring in data for the particular CustomerId; the SqlDataSource allows you to use a QueryStringParameter as part of the select statement to the database.

Each of the above controls have wizards that will allow you to easily configure them.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.