![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
@ Page Language="C#" MasterPageFile="~/Bobsleigh.master" AutoEventWireup="true"
CodeFile="EventSearch.aspx.cs" Inherits="EventSearch" Title="Untitled Page" %>
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxControlToolkit" %>
<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>
![](/Images/OutliningIndicators/None.gif)
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;
![](/Images/OutliningIndicators/None.gif)
public partial class EventSearch : System.Web.UI.Page
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
//joey
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
"Page_Load"#region "Page_Load"
protected void Page_Load(object sender, EventArgs e)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Page.Title = ConfigurationManager.AppSettings["WebsiteTitle"] + " - Search Event";
if (Session["UserSession"] != null)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
UserSession us = (UserSession)Session["UserSession"];
if (!us.SecurityCheck(us, (int)PermissionIdentity.UserPermission.Search_Event))
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Response.Redirect("UserDetails.aspx", true);
}
}
else
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Response.Redirect("BobsleighLogin.aspx", true);
}
if (!this.IsPostBack)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
CacheManager.bindDropDownList(this.ddlDiscipline, CacheManager.cachedList.Sport_Discipline.ToString(), 0);
}
}
#endregion
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
"btnSearch_Click"#region "btnSearch_Click"
protected void btnSearch_Click(object sender, EventArgs e)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (string.IsNullOrEmpty(this.gvEvent.DataSourceID))
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.gvEvent.DataSourceID = "odsEvent";
}
this.gvEvent.DataBind();
}
#endregion
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
"gvEvent_RowDataBound"#region "gvEvent_RowDataBound"
protected void gvEvent_RowDataBound(object sender, GridViewRowEventArgs e)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
if (e.Row.RowType == DataControlRowType.DataRow)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
Event ev = (Event)e.Row.DataItem;
HyperLink hlEventName = (HyperLink)e.Row.FindControl("hlEventName");
hlEventName.NavigateUrl = "AddEvent.aspx?EventID=" + Encryption.Encrypt(ev.EventID.ToString());
hlEventName.Target = "_self";
hlEventName.Text = ev.EventTitle;
Label lblDate = (Label)e.Row.FindControl("lblDate");
lblDate.Text = ev.Date.ToShortDateString();
Track t = (Track)(new TrackDO()).retrieveTrack(ev.TrackID)[0];
Label lblTrackName = (Label)e.Row.FindControl("lblTrackName");
lblTrackName.Text = t.TrackName;
Label lblEventType = (Label)e.Row.FindControl("lblEventType");
lblEventType.Text = GetDiscipline(ev.Discipline);
Label lblTraining = (Label)e.Row.FindControl("lblTraining");
Label lblCompetition = (Label)e.Row.FindControl("lblCompetition");
if (ev.EventType)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
lblTraining.Text = "Yes";
lblCompetition.Text = "No";
}
else
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
lblTraining.Text = "No";
lblCompetition.Text = "Yes";
}
}
}
catch
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
}
}
#endregion
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
"GetDiscipline"#region "GetDiscipline"
private string GetDiscipline(string id)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
try
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return CacheManager.getCachedItemName(CacheManager.cachedList.Sport_Discipline.ToString(), Convert.ToInt32(id));
}
catch
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
return "";
}
}
#endregion
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
"odsEvent_Selecting"#region "odsEvent_Selecting"
protected void odsEvent_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
e.InputParameters["EventID"] = int.MinValue;
}
#endregion
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
"ddlTrack_DataBound"#region "ddlTrack_DataBound"
protected void ddlTrack_DataBound(object sender, EventArgs e)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
this.ddlTrack.Items.Insert(0, new ListItem("", ""));
}
#endregion
//end
}
![](/Images/OutliningIndicators/None.gif)
posted @
2008-03-27 22:26
N/A2011
阅读(
256)
评论()
编辑
收藏
举报