aspboundfield headertextfirst name datafieldaufname

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ectionString="server=localhost;database=pubs;integrated security=true" SelectCommand="select title_id, title, price from titles" /> <asp:DataGrid DataSourceID="Titles" RunAt="server" /> Key SqlDataSource Properties Name Description ConnectionString Connection string used to connect to data source SelectCommand Command used to perform queries InsertCommand Command used to perform inserts UpdateCommand Command used to perform updates DeleteCommand Command used to perform deletes DataSourceMode Specifies whether DataSet or DataReader is used (default = DataSet) ProviderName Specifies provider (default = SQL Server .NET provider) 22 Parameterized Commands XxxParameters properties permit database commands to be parameterized Example: Get value for WHERE clause in SelectCommand from query string parameter or item selected in drop-down list Example: Get value for WHERE clause in DeleteCommand from GridView XxxParameter types specify source of parameter values XxxParameter Types Name Description Parameter Binds a replaceable parameter to a data field ControlParameter Binds a replaceable parameter to a control property CookieParameter Binds a replaceable parameter to a cookie value FormParameter Binds a replaceable parameter to a form field QueryStringParameter Binds a replaceable parameter to a query string parameter SessionParameter Binds a replaceable parameter to a session variable 23 SqlDataSource Example 1 <%@ Page Language="C#" %> <html> <head runat="server"> <title>GridView Bound to SqlDataSource</title> </head> <body> <form id="form1" runat="server"> <asp:GridView ID="GridView1" DataSourceID="SqlDataSource1" asp:GridView runat="server" /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" SelectCommand="SELECT [au_id], [au_lname], [au_fname], [phone], [address], [city], [state], [zip], [contract] FROM [authors]" ConnectionString="<%$ ConnectionStrings:Pubs %>" /> </form> </body> </html> SqlDataSource Example 2 <%@ Page Language="C#" %> <html> <head id="Head1" runat="server"> <title>Updating Data Using GridView</title> </head> <body> <form id="form1" runat="server"> <asp:GridView ID="GridView1" AllowSorting="true" AllowPaging="true" Runat="server" DataSourceID="SqlDataSource1" AutoGenerateEditButton="true" DataKeyNames="au_id" AutoGenerateColumns="False"> <Columns> <asp:BoundField ReadOnly="true" HeaderText="ID" DataField="au_id" SortExpression="au_id" /> <asp:BoundField HeaderText="Last Name" DataField="au_lname" SortExpression="au_lname" /> <asp:BoundField HeaderText="First Name" DataField="au_fname" SortExpression="au_fname" /> <asp:BoundField HeaderText="Phone" DataField="phone" SortExpression="phone" /> <asp:BoundField HeaderText="Address" DataField="address" SortExpression="address" /> <asp:BoundField HeaderText="City" DataField="city" SortExpression="city...
View Full Document

This note was uploaded on 04/04/2014 for the course CS 5950 taught by Professor Staff during the Summer '08 term at Western Michigan.

Ask a homework question - tutors are online