Click here to Skip to main content
15,886,071 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I m using following code for binding database table with datagrid.But data is not showing on datagrid.How can i solve it?


C#
con.Open();

adap = new SqlDataAdapter("select * from details", con);
DataTable dt = new DataTable("details");

adap.Fill(dt);


dataGrid1.ItemsSource = dt.DefaultView;
con.Close();
Posted
Updated 1-Dec-13 9:16am
v4
Comments
Varsha Ramnani 30-Nov-13 4:38am    
Have you checked that there is data in dt after adap.Fill(dt) line is executed?
Member 10346894 30-Nov-13 4:41am    
Yes,dt is showing table.,
Varsha Ramnani 30-Nov-13 4:55am    
what is the value of AutoGenerateColumns property of datagrid if it is set to false then have you created columns and set the binding to respective columns in datatable?
Member 10346894 30-Nov-13 6:32am    
I have solved this problem.I also used same procedure.Thanks Varsha

1 solution

 
Share this answer
 

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