Datagrid binding takes more time

Mar 2, 2011 at 5:25 AM

Hi,

   I am binding dataset to datagrid. It takes lot of time to bind the data. Below is what I am doing

XAML:

        <WpfToolkit:DataGrid x:Name="DataGridCurrentValue" ItemsSource="{Binding Path=QueriedData}" ColumnHeaderHeight="25"  RowHeight="25" Background="Black" Width="Auto" MinColumnWidth="200"></WpfToolkit:DataGrid>

 

CS

public MainWindow()     {            

 InitializeComponent();

static string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = D:\\PresentWork\\CustomDataGrid\\CustomDataGrid\\bin\\Database\\TestDatabase.mdb";

 string sql = "SELECT * from testdata";

 DataSet ds = new DataSet();            

OleDbConnection conn = new OleDbConnection(connectionString);            

OleDbCommand cmd = new OleDbCommand(strSelectQuery, conn);            

OleDbDataAdapter oda = new OleDbDataAdapter(cmd);            

oda.Fill(ds, "QueriedData");          //Program runs till here with a good speed  

DataGridCurrentValue.DataContext = ds; //Here at this line the program takes lots of time. More than 6 sec

}

 

Issue Description:

The program fetches data from database within milli seconds. After fetching the data I am binding the data to the datagrid. The data binds well but takes lot of time to bind. The amount of data is very less. 3 columns and approximately 700 rows. Any suggestion to improve the performance.

 

Thanks,

Praveen

Mar 5, 2011 at 3:16 AM

I got the answer. I was using ScrollViewer.CanContentScroll="True" in my XAML which I missed while posting in my above query. To load the grid faster, I had to remove ScrollViewer.CanContentScroll. How ever by removing this I lost smooth scrolling.

 

Thanks,

Praveen