Using SQL Data Sources Efficiently

how to use sql data sources 416 431 n.w
1 / 17
Embed
Share

"Learn how to utilize SQL data sources effectively with the Query Builder, Dropdown Lists, Data Binding, and more. Simplify your SQL statement creation and enhance data management in your projects."

  • SQL Data
  • Query Builder
  • Data Binding
  • Efficient
  • Database

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. How to use SQL data sources [416 - 431] Vaideeswaran Kaliannan Presentation ID #23

  2. Overview Select statement with Query Builder Dropdown list - Data binding Define parameters Datalist control

  3. Select statement with Query Builder Much easier to create statement than entering the custom statement If we add two related table in the diagram panel, it automatically join two tables Add column by selecting the checkbox Sort and filter can be done in grid panel

  4. Query Designer Diagram panel Grid panel SQL panel

  5. Product list Dropdown list Data list Dropdown list Data list

  6. Dropdown List Data Binding We can bind any of the controls that inherit the ListControl class to a data source. It includes list box control, drop-down list control, check box control, radio button list control, and bulleted list control. Data Source Configuration Wizard to select datasource for the list control, the data field to display the list and data value to return for the selected item DataTextFormatString attribute of the list control to specify a format string that want to apply to the text that s displayed in the control.

  7. Continued <asp:DropDownList ID="ddlCategory" runat="server" DataSourceID="SqlDataSource1" DataTextField="LongName" DataValueField="CategoryID"> </asp:DropDownList><br /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:HalloweenConnectionString %>" SelectCommand="SELECT [CategoryID], [LongName] FROM [Categories] ORDER BY [LongName]"> </asp:SqlDataSource>

  8. Define the parameters If you specify one or more parameters when you use the Query Builder to define a Select statement, the next dailog box lets you define those parameters. To define a parameter, you specify the source of the value for each parameter. You can also specify the default value for the paramerter.

  9. Continued The source of the CategoryID parameter is set to the SelectedValue property of the control named SelectedValue property was selected by default. ddlCategory.The If you want to use a different property as the source for a parameter, click the Show Advanced Properties link to display a list of the parameter properties. Then, you can set the PropertyName to the control property you want to use.

  10. Template Editing Mode Header Template Item Template

  11. Bind the controls in a template Select the Edit DataBindings command from the smart tag menu. Then, select the property you want to bind to (usually Text), select the Field binding option, and select the field you want to bind. If you want to apply a format to the bound data, select a format from the Format drop down list. As you specify the binding for a control, Visual Studio generates a data binding expression that uses the Eval method. The Eval method provides only for displaying data from a data source in a control. In contrast, the Bind method provides for two-way binding, which means that it can be used to display as well update data from a data source.

  12. Syntax: <%# (Eval|Bind) (Namestring [, FormatString]) %> <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %> /> <asp:Label ID="lblUnitPrice" runat="server" Text='<%# Eval("UnitPrice", "{0:C}") %>' />

Related


More Related Content