我在ASP.net C#前端和Oracle 11g后端创建了一个网页。 网页由一个ASP日历,两个DropDownList和一个GridView组成。根据日期和DropDownList的选择,数据将显示在GridView中。但是,当我选择任何组合数据时,不会在网格视图中显示。但是,当我通过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%&#39 ;;数据从数据库中检索。
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();
}
}
}
答案 0 :(得分:0)
我正在使用像这样的日历控件
//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();
检查它是否对您有所帮助。
答案 1 :(得分:0)
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的链接