BindData() //自定义绑定
{
//里面就是查询出你删除后需要显示的数据 放到DataTable里
string sql="select * from ????? where ????";
DataTable dt=GetDataTable(sql,"");
//然后绑定到DataGrid上
this.dataGrid1.DataSource=dt
}
public DataTable GetDataTable(string sql,string tableName)
{
using(SqlConnection conn=GetConnection())
{
DataSet ds=new DataSet();
try
{
SqlCommand cmd=new SqlCommand(sql,conn);
SqlDataAdapter da=new SqlDataAdapter(cmd);
da.Fill(ds,tableName);
}
catch(SqlException ex)
{
Console.WriteLine(ex.Message);
}
return ds.Tables[tableName];
}
}
[此贴子已经被作者于2006-10-5 3:01:26编辑过]