Professional Documents
Culture Documents
NET
• As we have seen before, we can program using
ADO.NET in two ways
• By explicitly writing code to create
Connection, DataReader,
DataAdpater etc. and then binding them
with controls traditional way
• By dragging and dropping controls and
configuring them visually. DataBinding
New feature in ASP 2.0.
• We will use the 2nd approach in this session.
DataBinding
• ASP.NET includes a rich and full-featured model
for data binding.
• Data binding is a technique of binding asp.net
web controls to the Data Source controls so that
data is automatically fetched and shown.
• Data Source controls are the controls that links
itself with data sources like SQLserver, Oracle,
Access etc.
• Data binding is declarative, not programmatic.
Data Source Controls
Special data controls
DataSource controls
providerName="System.Data.SqlClient" />
</connectionStrings>
…
• This is what gets automatically added in web,config file
because of step 3.
What is the advantage of this?
Viewing the properties of
DataSource control
<DeleteParameters>
<asp:Parameter Name="EID" Type="Decimal" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="EID" Type="Decimal" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="EID" Type="Decimal" />
<asp:Parameter Name="Name" Type="String" />
</InsertParameters>
Data types enforced
</asp:SqlDataSource>
for the parameters
Binding GridView
• Drag and drop GridView
from the Data Controls
After delete
Specifying form parameters in the
select query
• Drag and drop a text box and a button on to the form.
• Select property of the SQLDataSource and go to select
query.
Try inserting,
updating and
deleting
Using stored procedures instead of
sql commands
<asp:SqlDataSource ID="SqlDataSource1"
runat="server"
ConnectionString="<%$
ConnectionStrings:EmployeeConnectionString
%>" …
UpdateCommand="UpdateEmployee"
UpdateCommandType="StoredProcedure“>
…
</asp:SqlDataSource>