More on ADO'Net 3'5 for Web Applications - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

More on ADO'Net 3'5 for Web Applications

Description:

Like the GridView, the DataList is ... Rather, you need to supply formatting in a series of templates. ... Bind('PizzaToppings', 'Generously Topped with {0} ... – PowerPoint PPT presentation

Number of Views:24
Avg rating:3.0/5.0
Slides: 11
Provided by: Chan138
Category:

less

Transcript and Presenter's Notes

Title: More on ADO'Net 3'5 for Web Applications


1
More on ADO.Net 3.5for Web Applications
2
Using the DataList Control
  • Like the GridView, the DataList is bound by
    setting its DataSource and DataMember properties
    and then calling the DataBind method. But unlike
    the GridView, the DataList has no built-in
    formatting. Rather, you need to supply formatting
    in a series of templates.
  • At a minimum, you need to supply an Item Template.

3
DataList (2)
  • Data Binding commands set off by lt gt
    makers.
  • lt Bind(PizzaToppings, Generously Topped with
    0) gt
  • PizzaToppings, is the name of the field to be
    evaluated
  • The 0 token in the format string is replaced
    with the results of the evaluation.

4
Repeater Control
  • Repeater control depends on Templates to provides
    all of its content
  • Repeater control does NOT have a design time
    interface. You need to specify the ItemTemplate
    in the Source viewltItemTemplategt
    ltEval(ItemSize) gt ltbr /gtlt/ItemTemplategt

5
Data View Controls
  • For displaying multiple records using
  • GridView
  • DataList
  • Repeater
  • For displaying a single record
  • DetailsView
  • FormView

6
Stored Procedures
  • A named precompiled query that is held
    permanently in the database.- known as prepared
    sql statements- most of the larger commercial
    databases also support stored procedures.-
    more efficient and faster- excellent for passing
    parameters

7
Stored Procedures and the Command Object
  • The command object can call stored procedures
    directly
  • set the Connection property of the command object
    to the connection you setup.
  • set the CommandText property to the name of the
    stored procedure.
  • Set the CommandType property to
    CommandType.StoredProcedure

8
Invoking Stored Procedures
  • Specify the connection string asdim cnn as New
    SqlConnection(ConfigurationManager.
    ConnectionStrings(StringName).ConnectionString)
  • Stored Procedure for data being retrieved
  • Dim MyCommand as New SqlCommandMyCommand.Conne
    ctioncnnMyCommand.CommandText
    "AddSurveyMyCommand.CommandType
    CommandType.StoredProcedure
  • Execute the Stored Procedure
  • cnn.open Dim I as integerMyCommand.ExecuteSc
    alar() Cnn.close Returen i

9
Parameterized Stored Procedures
  • After defining the database connection string,
    specify the sqlcommand class
  • Dim cmd1 as New SqlCommand cmd1.Connectioncnn
    cmd1.CommandText "AddSurvey cmd1.CommandType
    CommandType.StoredProcedure
  • Providing a Value for the Parametercmd1.Paramete
    rs.Add("_at_gender", SqlDbType.Int).Value
    gender.SelectedValue

10
Lab7 Exercises
Write a Comment
User Comments (0)
About PowerShow.com