objectdatasource sample
2008-03-27 22:26
260 查看
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<h1>
Event Search</h1>
<ajax:ScriptManager ID="ScriptManager1" runat="server">
</ajax:ScriptManager>
<div class="CommonContent">
<ajax:UpdatePanel ID="SearchPane" runat="server">
<ContentTemplate>
<table>
<tr>
<td>
<asp:Label runat="server" ID="lblMessage" ForeColor="red"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label runat="Server" ID="lblDate" CssClass="eventSearchPageLabel1">Date:</asp:Label>
<asp:TextBox runat="Server" ID="txtDate" CssClass="eventSearchPageTextBox1"></asp:TextBox>
<ajaxControlToolkit:CalendarExtender runat="server" ID="ceDate" TargetControlID="txtDate"
Format="MMMM d, yyyy">
</ajaxControlToolkit:CalendarExtender>
</td>
<td>
<asp:Label runat="Server" ID="lblEventName" CssClass="eventSearchPageLabel2">Event:</asp:Label>
<asp:TextBox runat="Server" ID="txtEventName" CssClass="eventSearchPageTextBox2"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:SqlDataSource ConnectionString="<%$ ConnectionStrings:ConnectionInfo %>" SelectCommand="
select
TrackID,
TrackName
from Track
" ID="sdsTrack" runat="Server"></asp:SqlDataSource>
<asp:Label runat="Server" ID="lblTrack" CssClass="eventSearchPageLabel1">Venue:</asp:Label>
<asp:DropDownList DataTextField="TrackName" DataValueField="TrackID" DataSourceID="sdsTrack"
runat="server" ID="ddlTrack" CssClass="eventSearchPageDropDownList1" AutoPostBack="True"
OnDataBound="ddlTrack_DataBound">
</asp:DropDownList>
</td>
<td>
<asp:Label runat="Server" ID="lblEventType" CssClass="eventSearchPageLabel2">Discipline:</asp:Label>
<asp:DropDownList runat="Server" ID="ddlDiscipline" CssClass="eventSearchPageDropDownList2"
AutoPostBack="True">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label runat="Server" ID="lblTraining" CssClass="eventSearchPageLabel1">Training:</asp:Label>
<asp:CheckBox runat="Server" ID="cbTraining" CssClass="eventSearchPageCheckBox1"
Checked="True" />
</td>
<td>
<asp:Label runat="Server" ID="lblCompetition" CssClass="eventSearchPageLabel2">Competition:</asp:Label>
<asp:CheckBox runat="Server" ID="cbCompetition" CssClass="eventSearchPageCheckBox2"
Checked="True" />
</td>
</tr>
<tr>
<td>
<asp:Button runat="Server" ID="btnSearch" Text="Search" OnClick="btnSearch_Click" />
</td>
</tr>
</table>
<asp:ObjectDataSource TypeName="Entities.EntityForEventSearchPage" runat="Server"
SelectMethod="SelectMethod" SortParameterName="SortParameter" ID="odsEvent" OnSelecting="odsEvent_Selecting">
<SelectParameters>
<asp:Parameter Name="EventID" Type="Int32" />
<asp:ControlParameter ControlID="txtDate" Type="DateTime" Name="Date" PropertyName="Text" />
<asp:ControlParameter ControlID="ddlDiscipline" Type="String" Name="Discipline" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="cbTraining" Type="Boolean" Name="Training" PropertyName="Checked" />
<asp:ControlParameter ControlID="cbCompetition" Type="Boolean" Name="Competition"
PropertyName="Checked" />
<asp:ControlParameter ControlID="txtEventName" Type="String" Name="EventTitle" PropertyName="Text" />
<asp:ControlParameter ControlID="ddlTrack" Type="String" Name="TrackID" PropertyName="SelectedValue" />
<asp:Parameter Name="SortParameter" Type="string" DefaultValue="EventID" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:GridView ID="gvEvent" AutoGenerateColumns="false" DataKeyNames="EventID" runat="server"
AlternatingRowStyle-BackColor="#eeeeee" RowStyle-BackColor="white" RowStyle-BorderColor="#dddddd"
RowStyle-BorderWidth="1" RowStyle-BorderStyle="Solid" BorderColor="#dddddd" BorderWidth="1"
CellPadding="5" CellSpacing="0" AllowSorting="true" OnRowDataBound="gvEvent_RowDataBound">
<Columns>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Event" SortExpression="EventTitle">
<ItemTemplate>
<asp:HyperLink runat="Server" ID="hlEventName"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Date" SortExpression="Date">
<ItemTemplate>
<asp:Label runat="server" ID="lblDate">
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Discipline" SortExpression="Discipline">
<ItemTemplate>
<asp:Label runat="Server" ID="lblEventType">
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Training" SortExpression="Training">
<ItemTemplate>
<asp:Label runat="Server" ID="lblTraining">
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Competition" SortExpression="Training">
<ItemTemplate>
<asp:Label runat="server" ID="lblCompetition">
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Venue" SortExpression="TrackName">
<ItemTemplate>
<asp:Label runat="server" ID="lblTrackName">
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</ajax:UpdatePanel>
</div>
</asp:Content>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using DAO;
using DomainObjects;
using System.Data.SqlClient;
public partial class EventSearch : System.Web.UI.Page
<h1>
Event Search</h1>
<ajax:ScriptManager ID="ScriptManager1" runat="server">
</ajax:ScriptManager>
<div class="CommonContent">
<ajax:UpdatePanel ID="SearchPane" runat="server">
<ContentTemplate>
<table>
<tr>
<td>
<asp:Label runat="server" ID="lblMessage" ForeColor="red"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label runat="Server" ID="lblDate" CssClass="eventSearchPageLabel1">Date:</asp:Label>
<asp:TextBox runat="Server" ID="txtDate" CssClass="eventSearchPageTextBox1"></asp:TextBox>
<ajaxControlToolkit:CalendarExtender runat="server" ID="ceDate" TargetControlID="txtDate"
Format="MMMM d, yyyy">
</ajaxControlToolkit:CalendarExtender>
</td>
<td>
<asp:Label runat="Server" ID="lblEventName" CssClass="eventSearchPageLabel2">Event:</asp:Label>
<asp:TextBox runat="Server" ID="txtEventName" CssClass="eventSearchPageTextBox2"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:SqlDataSource ConnectionString="<%$ ConnectionStrings:ConnectionInfo %>" SelectCommand="
select
TrackID,
TrackName
from Track
" ID="sdsTrack" runat="Server"></asp:SqlDataSource>
<asp:Label runat="Server" ID="lblTrack" CssClass="eventSearchPageLabel1">Venue:</asp:Label>
<asp:DropDownList DataTextField="TrackName" DataValueField="TrackID" DataSourceID="sdsTrack"
runat="server" ID="ddlTrack" CssClass="eventSearchPageDropDownList1" AutoPostBack="True"
OnDataBound="ddlTrack_DataBound">
</asp:DropDownList>
</td>
<td>
<asp:Label runat="Server" ID="lblEventType" CssClass="eventSearchPageLabel2">Discipline:</asp:Label>
<asp:DropDownList runat="Server" ID="ddlDiscipline" CssClass="eventSearchPageDropDownList2"
AutoPostBack="True">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label runat="Server" ID="lblTraining" CssClass="eventSearchPageLabel1">Training:</asp:Label>
<asp:CheckBox runat="Server" ID="cbTraining" CssClass="eventSearchPageCheckBox1"
Checked="True" />
</td>
<td>
<asp:Label runat="Server" ID="lblCompetition" CssClass="eventSearchPageLabel2">Competition:</asp:Label>
<asp:CheckBox runat="Server" ID="cbCompetition" CssClass="eventSearchPageCheckBox2"
Checked="True" />
</td>
</tr>
<tr>
<td>
<asp:Button runat="Server" ID="btnSearch" Text="Search" OnClick="btnSearch_Click" />
</td>
</tr>
</table>
<asp:ObjectDataSource TypeName="Entities.EntityForEventSearchPage" runat="Server"
SelectMethod="SelectMethod" SortParameterName="SortParameter" ID="odsEvent" OnSelecting="odsEvent_Selecting">
<SelectParameters>
<asp:Parameter Name="EventID" Type="Int32" />
<asp:ControlParameter ControlID="txtDate" Type="DateTime" Name="Date" PropertyName="Text" />
<asp:ControlParameter ControlID="ddlDiscipline" Type="String" Name="Discipline" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="cbTraining" Type="Boolean" Name="Training" PropertyName="Checked" />
<asp:ControlParameter ControlID="cbCompetition" Type="Boolean" Name="Competition"
PropertyName="Checked" />
<asp:ControlParameter ControlID="txtEventName" Type="String" Name="EventTitle" PropertyName="Text" />
<asp:ControlParameter ControlID="ddlTrack" Type="String" Name="TrackID" PropertyName="SelectedValue" />
<asp:Parameter Name="SortParameter" Type="string" DefaultValue="EventID" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:GridView ID="gvEvent" AutoGenerateColumns="false" DataKeyNames="EventID" runat="server"
AlternatingRowStyle-BackColor="#eeeeee" RowStyle-BackColor="white" RowStyle-BorderColor="#dddddd"
RowStyle-BorderWidth="1" RowStyle-BorderStyle="Solid" BorderColor="#dddddd" BorderWidth="1"
CellPadding="5" CellSpacing="0" AllowSorting="true" OnRowDataBound="gvEvent_RowDataBound">
<Columns>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Event" SortExpression="EventTitle">
<ItemTemplate>
<asp:HyperLink runat="Server" ID="hlEventName"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Date" SortExpression="Date">
<ItemTemplate>
<asp:Label runat="server" ID="lblDate">
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Discipline" SortExpression="Discipline">
<ItemTemplate>
<asp:Label runat="Server" ID="lblEventType">
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Training" SortExpression="Training">
<ItemTemplate>
<asp:Label runat="Server" ID="lblTraining">
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Competition" SortExpression="Training">
<ItemTemplate>
<asp:Label runat="server" ID="lblCompetition">
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Venue" SortExpression="TrackName">
<ItemTemplate>
<asp:Label runat="server" ID="lblTrackName">
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</ajax:UpdatePanel>
</div>
</asp:Content>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using DAO;
using DomainObjects;
using System.Data.SqlClient;
public partial class EventSearch : System.Web.UI.Page
相关文章推荐
- CodeSmith - NetTier 对于主从表级联显示的SAMPLE -- ObjectDataSource
- 业务逻辑>数据层>ObjectDataSource>数据源分页机制
- 关于ObjectDataSource
- 一个objectdatasource+gridview+multiple row update的例子
- Domain Object Layer Design and Sample Code for LiteMDA
- Design Pattern----04.Creational.Object Pool.Pattern (Java Sample)
- JSONObjectSample
- GridView 绑定 ObjectDataSource
- ObjectDataSourceMethodEventArgs的InputParameters 属性
- Asp.net学习笔记----使用GridView+ObjectDataSource进行自定义分页排序
- ObjectDataSourceMethodEventArgs的InputParameters 属性
- org/apache/commons/dpcp/BasicDataSource和org/apache/commons/pool/impl/GenericObjectPool
- 原创第一弹:ObjectDataSource相关属性及事件的理解
- ObjectDataSource+FormView灵活使用
- ObjectDataSource&&Gridview
- 从源代码解读spring之DataSource实现和FactoryBean模式(JndiObjectFactoryBean)
- Domain Object Layer Design and Sample Code for LiteMDA
- 技术笔记3_Asp.net:ObjectDataSource分页计算返回数据量的方法QueryStudentsCount必须返回int
- arcgis sample代码之SOE示例代码Length Calculator Server Object Extension的源码分析
- JS object factory and inherit sample