User (Old forums)MemberDecember 20, 2007 at 1:01 amPost count: 23064
I am trying to bind the DataGrid to a table in a DataSet using code in a Window1.cs file. When the table is filled, the DataGrid displays the headings and the correct number of rows but the data cells are blank. (I verified that the DataSet table is being filled by the tableAdapter.) Can anyone suggest what I am doing wrong? Similar code works for the WindowsForms DataGridView control.
public partial class Window1 : Window
private void button1_Click(object sender, RoutedEventArgs e)
adapter = new DataGridWithSql.Database1DataSetTableAdapters.PollensTableAdapter();
newDataSet = new Database1DataSet();
dataGridControl1.ItemsSource = newDataSet.Pollens;
And the xaml file has:
<xcdg:DataGridControl Margin=”44,100,48,53″ Name=”dataGridControl1″/>
inside a grid.
Is there some requirement to bind the DataGrid view with static tables in the static App function as in the example? If so, then how to call functions to modify and update the database from Windows.cs code? I have tried many permutations.
Imported from legacy forums. Posted by James (had 2929 views)User (Old forums)MemberDecember 20, 2007 at 9:44 amPost count: 23064
Read the documentation on how to bind to the datatable here..
Imported from legacy forums. Posted by nat (had 277 views)User (Old forums)MemberDecember 20, 2007 at 10:22 amPost count: 23064
Thank you for replying. I have been able to bind my DataBase to the DataGrid by following the example. The result is that the DataBase is displayed in the DataGrid when the program is launched. The example has binding code in the Application section. Due to my lack of understanding of how to communicate between the Windows code section and Application, I cannot do anything with the DataBase from Windows where the rest of my applicaiton lives. I need to be able to edit the DataBase and update it using code in Windows.cs.
So, either I need to do the databinding in Windows or understand how to communicate between the code in Windows and Application.
With the binding code in Applications, I have tried to access the properties using Application.Current.Properties with no success. With the binding code in Windows, I just get blank rows. There are too many permutations of things that I have tried to enumerate them here.
Confused and frustrated so far.
Imported from legacy forums. Posted by James (had 328 views)User (Old forums)MemberDecember 20, 2007 at 10:36 amPost count: 23064
OK. I’ve made a breakthrough. I can make the DataSet properties in App public and access them like App.myDataSet from within my Windows class.
Thank you again.
Imported from legacy forums. Posted by James (had 3833 views)
- You must be logged in to reply to this topic.