Import MS Access database to a SFDataGrid
Hi,
I'm trying to import a MS Access database to a SFDataGrid, since I'd like to use the filter and sorting for this control. I got it working for a WPF DataGrid using the tutorial here and then build the project, go to the Data Sources toolbar, make sure DataGrid is selected from the dropdown for the dataset and then drag and drop into the design view. I was unable to figure out how to add the SFDataGrid control as a custom control for this dataset (under Customized Control Binding). I have the code below after messing around with the DataGrid code, but it doesn't display any data -- only the headers.
What is the best way to import a MS Access database into a SFDataGrid?
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
xmlns:local="clr-namespace:AccessWPFTest" x:Class="AccessWPFTest.MainWindow"
Title="MainWindow"
mc:Ignorable="d"
d:DesignHeight="1280" d:DesignWidth="1080"
Loaded="Window_Loaded" >
<Page.Resources>
<local:TestDatabaseDataSet x:Key="testDatabaseDataSet"/>
<CollectionViewSource x:Key="test_1ViewSource" Source="{Binding Test_1, Source={StaticResource testDatabaseDataSet}}"/>
</Page.Resources>
<Grid DataContext="{StaticResource test_1ViewSource}">
<syncfusion:SfDataGrid x:Name="test_1DataGrid" ColumnSizer="Auto" ItemsSource="{Binding test_1ViewSource}" >
<syncfusion:SfDataGrid.Columns>
<syncfusion:GridTextColumn x:Name="number" HeaderText="Number" Binding.XmlNamespaceManager="{Binding Number}"/>
<syncfusion:GridTextColumn x:Name="number2" HeaderText="Number2" Binding.XmlNamespaceManager="{Binding Number2}"/>
</syncfusion:SfDataGrid.Columns>
</syncfusion:SfDataGrid>
</Grid>
</Page>
private void Window_Loaded(object sender, RoutedEventArgs e)
{
AccessWPFTest.TowerDatabaseDataSet towerDatabaseDataSet = ((AccessWPFTest.TowerDatabaseDataSet)(this.FindResource("towerDatabaseDataSet")));
// Load data into the table TW230kV_1. You can modify this code as needed.
AccessWPFTest.TowerDatabaseDataSetTableAdapters.TW230kV_1TableAdapter towerDatabaseDataSetTW230kV_1TableAdapter = new AccessWPFTest.TowerDatabaseDataSetTableAdapters.TW230kV_1TableAdapter();
towerDatabaseDataSetTW230kV_1TableAdapter.Fill(towerDatabaseDataSet.TW230kV_1);
System.Windows.Data.CollectionViewSource tW230kV_1ViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("tW230kV_1ViewSource")));
tW230kV_1ViewSource.View.MoveCurrentToFirst();
}
I'm trying to import a MS Access database to a SFDataGrid, since I'd like to use the filter and sorting for this control. I got it working for a WPF DataGrid using the tutorial here and then build the project, go to the Data Sources toolbar, make sure DataGrid is selected from the dropdown for the dataset and then drag and drop into the design view. I was unable to figure out how to add the SFDataGrid control as a custom control for this dataset (under Customized Control Binding). I have the code below after messing around with the DataGrid code, but it doesn't display any data -- only the headers.
What is the best way to import a MS Access database into a SFDataGrid?
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
xmlns:local="clr-namespace:AccessWPFTest" x:Class="AccessWPFTest.MainWindow"
Title="MainWindow"
mc:Ignorable="d"
d:DesignHeight="1280" d:DesignWidth="1080"
Loaded="Window_Loaded" >
<Page.Resources>
<local:TestDatabaseDataSet x:Key="testDatabaseDataSet"/>
<CollectionViewSource x:Key="test_1ViewSource" Source="{Binding Test_1, Source={StaticResource testDatabaseDataSet}}"/>
</Page.Resources>
<Grid DataContext="{StaticResource test_1ViewSource}">
<syncfusion:SfDataGrid x:Name="test_1DataGrid" ColumnSizer="Auto" ItemsSource="{Binding test_1ViewSource}" >
<syncfusion:SfDataGrid.Columns>
<syncfusion:GridTextColumn x:Name="number" HeaderText="Number" Binding.XmlNamespaceManager="{Binding Number}"/>
<syncfusion:GridTextColumn x:Name="number2" HeaderText="Number2" Binding.XmlNamespaceManager="{Binding Number2}"/>
</syncfusion:SfDataGrid.Columns>
</syncfusion:SfDataGrid>
</Grid>
</Page>
private void Window_Loaded(object sender, RoutedEventArgs e)
{
AccessWPFTest.TowerDatabaseDataSet towerDatabaseDataSet = ((AccessWPFTest.TowerDatabaseDataSet)(this.FindResource("towerDatabaseDataSet")));
// Load data into the table TW230kV_1. You can modify this code as needed.
AccessWPFTest.TowerDatabaseDataSetTableAdapters.TW230kV_1TableAdapter towerDatabaseDataSetTW230kV_1TableAdapter = new AccessWPFTest.TowerDatabaseDataSetTableAdapters.TW230kV_1TableAdapter();
towerDatabaseDataSetTW230kV_1TableAdapter.Fill(towerDatabaseDataSet.TW230kV_1);
System.Windows.Data.CollectionViewSource tW230kV_1ViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("tW230kV_1ViewSource")));
tW230kV_1ViewSource.View.MoveCurrentToFirst();
}
SIGN IN To post a reply.
2 Replies
CO
Coder
May 17, 2015 12:32 AM UTC
The Window_Loaded function was not edited properly; so that someone could replicate my problem in the future, could someone delete/replace that part from the OP with the following? Many thanks in advance.
private void Window_Loaded(object sender, RoutedEventArgs e)
{
AccessWPFTest.TestDatabaseDataSet testDatabaseDataSet = ((AccessWPFTest.TestDatabaseDataSet)(this.FindResource("testDatabaseDataSet")));
// Load data into the table Test_1. You can modify this code as needed.
AccessWPFTest.TestDatabaseDataSetTableAdapters.Test_1TableAdapter towerDatabaseDataSetTest_1TableAdapter = new AccessWPFTest.TestDatabaseDataSetTableAdapters.Test_1TableAdapter();
testDatabaseDataSetTest_1TableAdapter.Fill(testDatabaseDataSet.Test_1);
System.Windows.Data.CollectionViewSource test_1ViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("test_1ViewSource")));
test_1ViewSource.View.MoveCurrentToFirst();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
AccessWPFTest.TestDatabaseDataSet testDatabaseDataSet = ((AccessWPFTest.TestDatabaseDataSet)(this.FindResource("testDatabaseDataSet")));
// Load data into the table Test_1. You can modify this code as needed.
AccessWPFTest.TestDatabaseDataSetTableAdapters.Test_1TableAdapter towerDatabaseDataSetTest_1TableAdapter = new AccessWPFTest.TestDatabaseDataSetTableAdapters.Test_1TableAdapter();
testDatabaseDataSetTest_1TableAdapter.Fill(testDatabaseDataSet.Test_1);
System.Windows.Data.CollectionViewSource test_1ViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("test_1ViewSource")));
test_1ViewSource.View.MoveCurrentToFirst();
}
JG
Jai Ganesh S
Syncfusion Team
May 19, 2015 03:22 PM UTC
Hi Cindy,
Thank you for using Syncfusion products.
We have analyzed your query. Asupport incident has been created under your account to track the status of this query. Please log on to our support website to check for further updates https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents
Please let us know if you have any queries.
Thank you,
Jai Ganesh S
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
-
CO Coder
- May 17, 2015 12:15 AM UTC
- May 19, 2015 03:22 PM UTC