c#中datagrid绑定后怎么不显示数据了呢(数据源中有数据),只显示表头
代码如下:string sqlstr = "Data Source=.;Initial Catalog=communication;Integrated Security=True";
SqlConnection con = new SqlConnection(sqlstr);
DataSet ds = new DataSet();
try
{
con.Open();
string selectstr = "select * from device where name like '%" + textBox1.Text.Trim() + "%';";
SqlDataAdapter da = new SqlDataAdapter(selectstr, con);
int datarow = da.Fill(ds, "device");
con.Close();
dataGrid1.DataSource = ds.Tables["device"];
textBox1.Text = datarow.ToString();
ds.Clear();
}
catch (Exception ex)
{
con.Close();
ds.Clear();
MessageBox.Show(ex.Message);
}