Q. How do I create a data-aware web control that automatically binds to the data?
A. Drag a datasource onto a form. Make it use your SQL Server/Database/Table. Make it generate SELECT, INSERT, UPDATE and DELETE commands. Save the connection string to web.config.
Put a SqlDataSource on a form.
Name it ds_yourDatasetName.
On the web design view, click the setup arrow to configure the database.
Choose New Connection.
Data Source: Microsoft SQL Server
Provider: .Net Framework Provider
Server Name: yourSqlServerName
Use Windows Authentication
Select the database: yourDatabaseName
Do you want to save the connection in the application configuration file?: yes. Save this string as: yourConnectionString.
Configure the Select statement:
Choose the table, select the columns.
Create the INSERT, UPDATE and DELETE statements:
If you click Advanced and the Statement Creation options are grayed out try adding a Primary Key to your table. Select Advanced, Generate INSERT, UPDATE, and DELETE statements.
Saving the connection string created this in web.config:
‹add name="yourConnectionString"
connectionString="Data Source=yourSqlServerName;
Initial Catalog=yourTable;
Integrated Security=True"
providerName="System.Data.SqlClient" /›
Put a data-aware (e.g., FormView) control on the form. Task menu, Choose Data Source: ds_yourDatasetName.


{ 0 comments… add one now }
You must log in to post a comment.