//这是表示层的代码
BusinessAccessLayer.BLogic obj1 = new BusinessAccessLayer.BLogic();
string i = DDMenu.SelectedValue;
DataTable dt = new DataTable();
dt=obj1.getBind(i);
GridView1.DataSource = dt;
GridView1.DataBind();
//这是业务访问层的代码
DataAccessLayer.DBLogic obj1 = new DataAccessLayer.DBLogic();
public DataTable getBind(string i)
{
return obj1.getInstrument(i);
}
//这是数据库访问层的代码
public DataTable getInstrument(string i)
{
SqlConnection con = new SqlConnection(constr);
con.Open();
try
{
SqlCommand cmd = new SqlCommand("selectedval", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@category_id", i);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
catch
{
throw;
}
finally
{
con.Close();
}
}
这里我通过插入查询在sql server中插入了一些图像。但是在将数据绑定到gridview时,我无法在gridview中看到这些图像。