你调用的对象是空的。
这是我尝试从网格视图中删除 .. 行时遇到的错误
这是在.. page_load
gvDetails.DataSource =myBl.DeleteAllCountry(int.Parse(gvDetails.SelectedRow.ToString()));
在数据访问层
public DataTable DeleteCountry(int country_id)
{
DataTable dltcontry = new DataTable();
SqlConnection con = new SqlConnection(@"Data Source=a8-pc\sqlexpress;Integrated Security=True");
SqlDataAdapter da;
try
{
SqlCommand cmd = new SqlCommand();
cmd.connection= con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_DeleteCountry";
con.Open();
da = new SqlDataAdapter(cmd);
cmd.Parameters.AddWithValue("country_id", @country_id);
cmd.ExecuteNonQuery();
da.Fill(dltcontry);
con.Close();
}
在业务层代码就像
public DataTable DeleteAllCountry(int country_id)
{
return mydtLayer.DeleteCountry(country_id);
}