ASP 日历无法正常工作
ASP Calendar in not working properly
我在ASP.net C# 前端和Oracle 11g 后端创建了一个网页。
网页由一个ASP个日历、两个DropDownList和一个GridView组成。根据日期和 DropDownList 的 selection,数据将显示在 GridView 中。但是当我 select 时,任何组合数据都不会显示在网格视图中。但是,当我通过 sqldeveloper 在数据库中编写相同的查询时,即 SELECT PALLET_NO、DATA_STS、MERGE、PLANT_CD、SHIFT、RACK_NO FROM WI_PALLET WHERE PROD_CD = 'PET' AND INPUT_DT LIKE '24-06-15%';从数据库中检索数据。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OracleClient;
using System.Data;
using System.Configuration;
using System.Drawing;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
DataSet ds = new DataSet();
OracleConnection con = new OracleConnection("Data Source=10.31.41.103/ORCL;User ID=RL_PET;Password=RL_PET;Unicode=True");
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
Label1.Visible = false;
if (DropDownList1.Text == "Store In" && DropDownList2.Text == "ALL")
{
con.Open();
OracleDataAdapter a = new OracleDataAdapter("SELECT PALLET_NO, DATA_STS, MERGE, PLANT_CD, SHIFT, RACK_NO FROM WI_PALLET WHERE PROD_CD = 'PET' AND INPUT_DT LIKE '"+ Calendar1.SelectedDate.Date+"%' ORDER BY PALLET_NO ASC", con);
a.Fill(ds);
int count = ds.Tables[0].Rows.Count;
Label1.Text = count.ToString();
Label1.Visible = true;
GridView1.DataSource = ds;
GridView1.DataBind();
GridView1.Visible = true;
con.Close();
}
else if (DropDownList1.Text == "Store In")
{
con.Open();
OracleDataAdapter a = new OracleDataAdapter("SELECT PALLET_NO, DATA_STS, MERGE, PLANT_CD, SHIFT, RACK_NO FROM WI_PALLET WHERE PROD_CD = 'PET' AND INPUT_DT LIKE '" + Calendar1.SelectedDate.Date+"%' AND SHIFT = '" + DropDownList2.Text + "' ORDER BY PALLET_NO ASC", con);
a.Fill(ds);
int count = ds.Tables[0].Rows.Count;
Label1.Text = count.ToString();
Label1.Visible = true;
GridView1.DataSource = ds;
GridView1.DataBind();
GridView1.Visible = true;
con.Close();
}
}
}
我是这样使用日历控件的
//front end aspx page
<asp:Calendar ID="Calendar1" runat="server"
SelectionMode="Day"
ShowGridLines="True">
//aspx.cs file
Label1.Text = "The selected date is " + Calendar1.SelectedDate.ToShortDateString();
看看对你有没有帮助。
Lable1.Text = Calendar1.Selected.ToString("dd-MMMM-yyyy");
OracleDataAdapter a = new OracleDataAdapter("SELECT PALLET_NO, DATA_STS, MERGE, PLANT_CD, SHIFT, RACK_NO FROM WI_PALLET WHERE PROD_CD = 'PET' AND trunc(TO_DATE(INPUT_DT)) = '"+ Lable1.Text+"' ORDER BY PALLET_NO ASC", con);
这对我有用。
感谢@shreesha link
我在ASP.net C# 前端和Oracle 11g 后端创建了一个网页。 网页由一个ASP个日历、两个DropDownList和一个GridView组成。根据日期和 DropDownList 的 selection,数据将显示在 GridView 中。但是当我 select 时,任何组合数据都不会显示在网格视图中。但是,当我通过 sqldeveloper 在数据库中编写相同的查询时,即 SELECT PALLET_NO、DATA_STS、MERGE、PLANT_CD、SHIFT、RACK_NO FROM WI_PALLET WHERE PROD_CD = 'PET' AND INPUT_DT LIKE '24-06-15%';从数据库中检索数据。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OracleClient;
using System.Data;
using System.Configuration;
using System.Drawing;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
DataSet ds = new DataSet();
OracleConnection con = new OracleConnection("Data Source=10.31.41.103/ORCL;User ID=RL_PET;Password=RL_PET;Unicode=True");
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
Label1.Visible = false;
if (DropDownList1.Text == "Store In" && DropDownList2.Text == "ALL")
{
con.Open();
OracleDataAdapter a = new OracleDataAdapter("SELECT PALLET_NO, DATA_STS, MERGE, PLANT_CD, SHIFT, RACK_NO FROM WI_PALLET WHERE PROD_CD = 'PET' AND INPUT_DT LIKE '"+ Calendar1.SelectedDate.Date+"%' ORDER BY PALLET_NO ASC", con);
a.Fill(ds);
int count = ds.Tables[0].Rows.Count;
Label1.Text = count.ToString();
Label1.Visible = true;
GridView1.DataSource = ds;
GridView1.DataBind();
GridView1.Visible = true;
con.Close();
}
else if (DropDownList1.Text == "Store In")
{
con.Open();
OracleDataAdapter a = new OracleDataAdapter("SELECT PALLET_NO, DATA_STS, MERGE, PLANT_CD, SHIFT, RACK_NO FROM WI_PALLET WHERE PROD_CD = 'PET' AND INPUT_DT LIKE '" + Calendar1.SelectedDate.Date+"%' AND SHIFT = '" + DropDownList2.Text + "' ORDER BY PALLET_NO ASC", con);
a.Fill(ds);
int count = ds.Tables[0].Rows.Count;
Label1.Text = count.ToString();
Label1.Visible = true;
GridView1.DataSource = ds;
GridView1.DataBind();
GridView1.Visible = true;
con.Close();
}
}
}
我是这样使用日历控件的
//front end aspx page
<asp:Calendar ID="Calendar1" runat="server"
SelectionMode="Day"
ShowGridLines="True">
//aspx.cs file
Label1.Text = "The selected date is " + Calendar1.SelectedDate.ToShortDateString();
看看对你有没有帮助。
Lable1.Text = Calendar1.Selected.ToString("dd-MMMM-yyyy");
OracleDataAdapter a = new OracleDataAdapter("SELECT PALLET_NO, DATA_STS, MERGE, PLANT_CD, SHIFT, RACK_NO FROM WI_PALLET WHERE PROD_CD = 'PET' AND trunc(TO_DATE(INPUT_DT)) = '"+ Lable1.Text+"' ORDER BY PALLET_NO ASC", con);
这对我有用。 感谢@shreesha link