Click here to Skip to main content
15,893,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My code is not showing data in datagrid

C#
SqlDataAdapter da = new SqlDataAdapter("Select Companyid from Accounts where Companyid= 1 ", con);
            DataSet ds = new DataSet();
            da.Fill(ds);

            DataGrid.ItemsSource = ds.Tables[0].ToString();
Posted

 
Share this answer
 
Comments
Rockstar_ 24-May-13 0:11am    
Good link...
Zain ul abdeen 24-May-13 0:12am    
Worked well but there is something at runtime I dont know how much data i will retrieve from database and i want to set scroll bars for my datagrid if you can help?
Pallavi Waikar 24-May-13 0:25am    
try HorizontalScrollBarVisibility="Visible" property of datagrid.
Zain ul abdeen 24-May-13 0:33am    
Ah! thankyou so much it make my life easier :)
SqlDataAdapter da = new SqlDataAdapter("Select Companyid from Accounts where Companyid= 1 ", con);
DataSet ds = new DataSet();
da.Fill(ds);

DataGrid.DataSource = ds.Tables[0];//change like this its enough
 
Share this answer
 
Comments
Zain ul abdeen 24-May-13 0:02am    
its in xaml.cs when I type . after datagrid it doesnot show DATASOURCE thats why i put utems source
Arun Vasu 24-May-13 0:21am    
ok i will try and tell you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900