ASP.net CS0029: 无法将类型“int”隐式转换为“string”
这句是作为sql的查询语句:id为bigint类型,stringquery=string.Format("select*fromddwhereidlike'%{0}%'o...
这句是作为sql的查询语句:id为bigint类型,
string query = string.Format("select * from dd where id like '%{0}%' order by id desc",tbx_key.Text);
该怎么改?
抱歉!完整代码应该是这样!一直出错!
protected void btn_search_Click(object sender, EventArgs e)
{
string query;
if (tbx_key.Text != "")
{
switch (DropDownList1.SelectedItem.Value)
{
case 0: query = string.Format("select * from dd where bianhao like '%{0}%' order by bianhao desc", tbx_key.Text); break;
case 1: query = string.Format("select * from dd where name like '%{0}%' order by bianhao desc", tbx_key.Text); break;
case 2: query = string.Format("select * from dd where huifu like '%{0}%' order by bianhao desc", tbx_key.Text); break;
}
DataSet ds = myset.getds(query);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
}
else
{
}
}
解决了原来是DropDownList1.SelectedItem.Value要强制转换为int 展开
string query = string.Format("select * from dd where id like '%{0}%' order by id desc",tbx_key.Text);
该怎么改?
抱歉!完整代码应该是这样!一直出错!
protected void btn_search_Click(object sender, EventArgs e)
{
string query;
if (tbx_key.Text != "")
{
switch (DropDownList1.SelectedItem.Value)
{
case 0: query = string.Format("select * from dd where bianhao like '%{0}%' order by bianhao desc", tbx_key.Text); break;
case 1: query = string.Format("select * from dd where name like '%{0}%' order by bianhao desc", tbx_key.Text); break;
case 2: query = string.Format("select * from dd where huifu like '%{0}%' order by bianhao desc", tbx_key.Text); break;
}
DataSet ds = myset.getds(query);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
}
else
{
}
}
解决了原来是DropDownList1.SelectedItem.Value要强制转换为int 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询