数据源的类型无效。它必须是 IListSource、IEnumerable 或 IDataSource。 10
protectedvoidButton3_Click(objectsender,EventArgse){DataSetds=newDataSet();SQLHelperh...
protected void Button3_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
SQLHelper hh = new SQLHelper();
if (DropDownList1.SelectedValue == "查询全部")
{
SqlParameter[] prams = { };
ds = hh.ExecuteDataSet("tblNews_GetAll", prams);
}
if (DropDownList1.SelectedValue == "按编号查询")
{
int NewsId = Convert.ToInt32(TextBox1.Text);
SqlParameter[] prams = {
new SqlParameter("@NewsId",SqlDbType.Int)
};
prams[0].Value = NewsId;
ds = hh.ExecuteDataSet("tblNews_GetId", prams);
}
if (DropDownList1.SelectedValue == "按时间查询")
{
DateTime NewsTime = Convert.ToDateTime(TextBox1.Text);
SqlParameter[] prams = {
new SqlParameter("@NewsTime",SqlDbType.DateTime)
};
prams[0].Value = NewsTime;
ds = hh.ExecuteDataSet("tblNews_GetTime", prams);
}
if (DropDownList1.SelectedValue == "按标题查询")
{
string NewsTitle = TextBox1.Text;
SqlParameter[] prams = {
new SqlParameter("@NewsTitle",SqlDbType.NVarChar)
};
prams[0].Value = NewsTitle;
ds = hh.ExecuteDataSet("tblNews_GetTitle", prams);
}
if (DropDownList1.SelectedValue == "按作者查询")
{
string NewsAuthor = TextBox1.Text;
SqlParameter[] prams = {
new SqlParameter("@NewsAuthor",SqlDbType.NVarChar)
};
prams[0].Value = NewsAuthor;
ds = hh.ExecuteDataSet("tblNews_GetAuthor", prams);
}
GridView1.DataSource = hh;
GridView1.DataBind(); 展开
{
DataSet ds = new DataSet();
SQLHelper hh = new SQLHelper();
if (DropDownList1.SelectedValue == "查询全部")
{
SqlParameter[] prams = { };
ds = hh.ExecuteDataSet("tblNews_GetAll", prams);
}
if (DropDownList1.SelectedValue == "按编号查询")
{
int NewsId = Convert.ToInt32(TextBox1.Text);
SqlParameter[] prams = {
new SqlParameter("@NewsId",SqlDbType.Int)
};
prams[0].Value = NewsId;
ds = hh.ExecuteDataSet("tblNews_GetId", prams);
}
if (DropDownList1.SelectedValue == "按时间查询")
{
DateTime NewsTime = Convert.ToDateTime(TextBox1.Text);
SqlParameter[] prams = {
new SqlParameter("@NewsTime",SqlDbType.DateTime)
};
prams[0].Value = NewsTime;
ds = hh.ExecuteDataSet("tblNews_GetTime", prams);
}
if (DropDownList1.SelectedValue == "按标题查询")
{
string NewsTitle = TextBox1.Text;
SqlParameter[] prams = {
new SqlParameter("@NewsTitle",SqlDbType.NVarChar)
};
prams[0].Value = NewsTitle;
ds = hh.ExecuteDataSet("tblNews_GetTitle", prams);
}
if (DropDownList1.SelectedValue == "按作者查询")
{
string NewsAuthor = TextBox1.Text;
SqlParameter[] prams = {
new SqlParameter("@NewsAuthor",SqlDbType.NVarChar)
};
prams[0].Value = NewsAuthor;
ds = hh.ExecuteDataSet("tblNews_GetAuthor", prams);
}
GridView1.DataSource = hh;
GridView1.DataBind(); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询