SqlDataAdapter da = new SqlDataAdapter("select * from tblTest", str);
DataSet ds = new DataSet();
da.Fill(ds);
dataGrid1.DataSource = ds;
tblTest has 10 columns. But after I fill it, only one column gets displayed in the datagrid. I put a column count after the fill statement to be sure it wasn't anything up to that point, but as far as I can tell something is going wrong when the datagrid's source is assigned. Any ideas what might be wrong?
Having problem filling dataset with sqldataadapter
Started by hoser2001, Jul 07 2006 06:52 AM
3 replies to this topic
#1
Posted 07 July 2006 - 06:52 AM
|
|
|
#2
Posted 07 July 2006 - 07:10 AM
Hmm, interesting. Everything looks good.
Here is the code from MSDN
The way you are filling it may be the problem. Try
Let me know if that works or not.
Here is the code from MSDN
private static DataSet SelectRows(DataSet dataset,
string connectionString,string queryString)
{
using (SqlConnection connection =
new SqlConnection(connectionString))
{
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand(
queryString, connection);
adapter.Fill(dataset);
return dataset;
}
}
The way you are filling it may be the problem. Try
dataGrid1.DataSource=ds.Tables["tblTest"];
Let me know if that works or not.
#3
Posted 07 July 2006 - 07:23 AM
No, still no go... Is it possible I have to use tablestyles or something of the sort?
#4
Posted 08 July 2006 - 08:41 AM
Are you using defined (templated) columns? Do you have AutoCreateColumns = True in the aspx or codebehind?


Sign In
Create Account


Back to top









