在将值解析为数据集“GetSubmitDataBy”时,我收到此错误。我从2个下拉列表中获取值,包括状态和集群,以及2个文本框,包括开始日期和结束日期。
protected void Button1_Click(object sender, EventArgs e)
{
RunTimeDSTableAdapters.tbl_runtime_reportTableAdapter state = new RunTimeDSTableAdapters.tbl_runtime_reportTableAdapter();
DataTable dt = new DataTable();
DateTime dt1 = Convert.ToDateTime(TextBox1_CalendarExtender.SelectedDate);
DateTime dt2 = Convert.ToDateTime(TextBox2_CalendarExtender.SelectedDate);
dt1.ToString("MM/DD/YYYY");
dt2.ToString("MM/DD/YYYY");
dt = state.GetSubmitDataBy(DropDownList1.SelectedValue, dt1, dt2, DropDownList2.SelectedValue);
GridView1.DataSource = dt;
GridView1.DataBind();
}
GetSubmitDataBy的签名是:
public virtual RunTimeDS.tbl_runtime_reportDataTable GetSubmitDataBy(string Cluster, string startDate, string endDate, string State) {
this.Adapter.SelectCommand = this.CommandCollection[2];
if ((Cluster == null)) {
this.Adapter.SelectCommand.Parameters[0].Value = global::System.DBNull.Value;
}
else {
this.Adapter.SelectCommand.Parameters[0].Value = ((string)(Cluster));
}
if ((startDate == null)) {
this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value;
}
else {
this.Adapter.SelectCommand.Parameters[1].Value = ((string)(startDate));
}
if ((endDate == null)) {
this.Adapter.SelectCommand.Parameters[2].Value = global::System.DBNull.Value;
}
else {
this.Adapter.SelectCommand.Parameters[2].Value = ((string)(endDate));
}
if ((State == null)) {
this.Adapter.SelectCommand.Parameters[3].Value = global::System.DBNull.Value;
}
else {
this.Adapter.SelectCommand.Parameters[3].Value = ((string)(State));
}
RunTimeDS.tbl_runtime_reportDataTable dataTable = new RunTimeDS.tbl_runtime_reportDataTable();
this.Adapter.Fill(dataTable);
return dataTable;
}
}
}
答案 0 :(得分:1)
dt1.ToString("MM/DD/YYYY");
dt2.ToString("MM/DD/YYYY");
什么都不做!
你必须改正行
dt = state.GetSubmitDataBy(DropDownList1.SelectedValue.ToString(), dt1.ToString("MM/DD/YYYY"), dt2.ToString("MM/DD/YYYY"), DropDownList2.SelectedValue.ToString());