DataGridView的列如何与数据源的列绑定?
使用下面的代码可以查询出结果,DataGridView没有设置列时,能够显示数据,但提前设置了列就不能显示数据了,如何绑定呀! 谢谢
SqlConnection oConnect; SqlCommand oCommand; string strConnect; strConnect = ConfigurationManager.ConnectionStrings["receive.Properties.Settings.newConnection"].ConnectionString; oConnect = new SqlConnection(strConnect); oCommand = new SqlCommand(); oCommand.Connection = oConnect; oCommand.CommandText = @"SELECT * FROM RECEIVABLES WHERE ISREAD='0'"; SqlDataAdapter sda = new SqlDataAdapter(oCommand); DataSet ds = new DataSet(); sda.Fill(ds); dataGridView3.DataSource = ds.Tables[0].DefaultView;