Sie sind auf Seite 1von 14

WEB ENGINEERING-II

USING ASP.NET
BY
ADNAN AMIN
LECTURER / SOFTWARE PROGRAMMER
INFORMATION AND COMMUNICATION TECHNOLOGY (ICT DEPT)
OVERVIEW
• Configuring sql data source
• Codes Creating connection
• Coding for Configure sql data source
• Add & configure the datagrid controls
• Important features for datagrid control
• Add & configure the datalist controls
• Add & configure the DetailView controls
CONFIGURING SQL DATA SOURCE
• First Create a new web site.
• Add Web form from Website menu by clicking Add New Item.
• Add SqlDataSource Server Control from the ToolBox.
• Drag and Drop onto Web Form.
• Click on Configure Data Source
from the Pop up menu.
STEP:1 CREATING CONNECTION
• Click on the New Connection Button.
STEP:2
1. Enter the Server name
e.g:
COMPUTER1/SQLEXPRESS

2. Select or Enter a database


name
e.g:
Northwind

Click on Ok Button.
SAVE THE CONNECTION STRING TO THE APPLICATION
CONFIGURATION FILE

Enter Any name for new connection or just Click on the check box.
Yes, save this connection as:
CONFIGURE THE SELECT STATEMENT
CODES CREATING CONNECTION
• Open Web.config page.
<configuration>
<appSettings/>
<connectionStrings>
<add
name="NorthwindConnectionString"
connectionString="Data Source=COMPUTER1\SQLEXPRESS;
Initial Catalog=Northwind;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
CODING FOR CONFIGURE
SQL DATA SOURCE

Default.aspx
Add SqlDataSource on to web form.
<body>
<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
ConnectionString=“
<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [ProductID], [ProductName],
[CategoryID] FROM [Products]">
</asp:SqlDataSource>
</body>
ADD & CONFIGURE THE DATAGRID
CONTROLS

• Create Page1.aspx from Add new Item (web site menu)


• Add DataGrid Control from the Data category of toolbox.
• Select the Data Source from the Drop Down
List.
IMPORTANT FEATURES FOR DATAGRID CONTROL

• Enable Paging
• Enable Sorting
• Enable Selection
ADD & CONFIGURE THE
DATALIST CONTROLS
• Create Page2.aspx from Add new Item (web site menu)
• Add DataList Control from the Data category of toolbox.
• Select the Data Source from the Drop Down
List.
ADD & CONFIGURE THE DETAIL
VIEW CONTROLS
• Create Page3.aspx from Add new Item (web site menu)
• Add DetailView Control from the Data category of toolbox.
• Select the Data Source from the Drop Down
List.
ASSIGNMENT
Differentiate DataList, DataGrid, DetailView and FormView
Control.

Das könnte Ihnen auch gefallen