public void BindData() { Score_Day_BLL bll = new Score_Day_BLL(); DateTime startTime = DateTime.Parse(DropDownList_Year.SelectedItem.Value + "-" + DropDownList_Month.SelectedItem.Value + "-01"); DateTime endTime = startTime.AddMonths(1).AddDays(-1); List <PF.Models.SQL.Score_Day> list = new List <Score_Day>(); if (DropDownList_YBUser.SelectedItem.Value == "全部") { list = bll.GetList(a => a.YBDate >= startTime && a.YBDate <= endTime && a.YBTime == DropDownList_YBTime.SelectedItem.Value).OrderBy(a => a.YBDate).ToList(); } else { list = bll.GetList(a => a.YBDate >= startTime && a.YBDate <= endTime && a.YBTime == DropDownList_YBTime.SelectedItem.Value && a.YBUserName == DropDownList_YBUser.SelectedItem.Value).OrderBy(a => a.YBDate).ToList(); } GridView_List.DataSource = list; GridView_List.DataBind(); }
public void BindData() { WarnCheck_BLL bll = new WarnCheck_BLL(); DateTime startTime = DateTime.Parse(DropDownList_Year.SelectedItem.Value + "-" + DropDownList_Month.SelectedItem.Value + "-01"); DateTime endTime = startTime.AddMonths(1); List <PF.Models.SQL.WarnCheck> list = bll.GetList(a => a.ReleaseTime >= startTime && a.ReleaseTime < endTime).ToList(); if (DropDownList_WarnCategory.SelectedItem.Value != "全部") { list = list.Where(a => a.WarningCategory == DropDownList_WarnCategory.SelectedItem.Value).ToList(); } if (DropDownList_WarnLevel.SelectedItem.Value != "全部") { list = list.Where(a => a.WarningLevel == DropDownList_WarnLevel.SelectedItem.Value).ToList(); } GridView_List.DataSource = list.OrderBy(a => a.ReleaseTime); GridView_List.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserName"] == null) { Response.Redirect("Login.aspx"); } SqlCommand command = new SqlCommand(); SqlDataAdapter adapter = new SqlDataAdapter(); DataSet ds = new DataSet(); int i = 0; string sql = null; string connetionString = @"data source= TIRTHAK\SQLEXPRESS; initial catalog=My project; integrated security=true"; SqlConnection connection = new SqlConnection(connetionString); connection.Open(); command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "getCustomerlist"; adapter = new SqlDataAdapter(command); adapter.Fill(ds); connection.Close(); GridView_List.DataSource = ds.Tables[0]; GridView_List.DataBind(); }
protected void GridView_List_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView_List.PageIndex = e.NewPageIndex; GridView_List.DataBind(); }