无法将类型“int”隐式转换为“string”
protected void ButAdd_Click(object sender, EventArgs e)//添加按钮
{
Model.Goods goods = new Model.Goods();
string GoodsType = DdlAddType.SelectedValue.ToString().Trim();//获取下拉列表框所选的类型名称
goods.TypeID = Convert.ToInt32(BLL.GoodsManager.getTypeId(GoodsType).Tables[0].Rows[0][0]);//将类型名 称传入getTypeId方法,获取TypeID
}
Goods是个商品类,它有个int型字段TypeID,TypeID与商品类型表tbl_type中的TypeID关联,在业务层BLL.GoodsManager类中有下面这个方法:
public static DataSet getTypeId(string GoodsType) //获取TypeID并返回一个dataset
{
string sql = "select id from tbl_type where type_name='" + GoodsType + "'";
DataSet ds = DAL.DBHelper.getDS(sql);
return ds;
}
为什么在点添加按钮后,编译器老是报错,无法将类型“int”隐式转换为“string”,错误的就是:
goods.TypeID = Convert.ToInt32(BLL.GoodsManager.getTypeId(GoodsType).Tables[0].Rows[0][0]);这句,
请大家帮忙看看啊,谢谢了。