This is a migrated thread and some comments may be shown as answers.

Refresh RadGridview in Wpf

4 Answers 1409 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rikin Patel
Top achievements
Rank 1
Rikin Patel asked on 25 Mar 2010, 05:43 PM

WPF and C#: Problem: 1. How to Refresh Radgridview when i Insert,update and Delete Record in database anrecord. 2.when i am Insert or Update Record than in radgridview that row is selected.

i am useing sql server 2005.

i am use to set data source of radgridview like " radgridview1.ItemsSource = ds; " ==> ds is dataset.

i am beginner so if possible than tel me by code it is easy to understand.......

can u help me as early as possible ....

i give some code which i am useing for update RadGridview

con.ConnectionString = @"Data Source=(local);Initial Catalog=DigiDms;Integrated Security=True"
 
        cmd1.Connection = con; 
        con.Open(); 
        cmd1.CommandType = CommandType.StoredProcedure; 
        cmd1.CommandText = "Pro_Insurance_Master_Select"
        da1.SelectCommand = cmd1; 
        da1.Fill(ds1); 
        con.Close(); 
 
        //dataGrid.clear(); 
        //dsGrid.Reset(); 
        //dsGrid = dataGrid.GetData("Pro_Insurance_Master_Select"); //set datasource of gridview 
 
        gridShowData.ItemsSource = null; // At hear i get Error
        gridShowData.ItemsSource = ds1; 

doing this ,

when i am delete or update record than folloning error generated... Error: >> "Object reference not set to an object"
when i am doing the "gridShowData.ItemsSource = null;"

and when i am doing insert operation than this error is not generated and RadGridview also updated.....

so pls help me as early as possible.... i am beginer ........

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 26 Mar 2010, 07:59 AM
Hi,

To refresh the grid you can call Rebind(). Can you post the exception stack trace?

Kind regards,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Rikin Patel
Top achievements
Rank 1
answered on 26 Mar 2010, 12:37 PM
When i am Rebinding than Gridview data is clear.......

Exception is :"Object reference not set to an object"
0
Stefan Dobrev
Telerik team
answered on 26 Mar 2010, 12:54 PM
Hello Rikin,

It is unclear from your pasted code what the problem might be. Can you send us a small sample application which illustrates your issue exactly? This will help us providing you with a working solution to your problem faster.

Best wishes,
Stefan Dobrev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Rikin Patel
Top achievements
Rank 1
answered on 30 Mar 2010, 01:48 PM



  

hi,

thk u 4 ur reply,

i am useing selected row event in this we get the information about selected row ...

so for that i use Gridview1.selectedItem but instead of this we use Gridview1.CurrentItem

and

before Reload the data in Gridview, we make null the selected item of Gridview

so Gridview1.SelectedItem = null;

so enjoy sharing idea to other........



Tags
GridView
Asked by
Rikin Patel
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Rikin Patel
Top achievements
Rank 1
Stefan Dobrev
Telerik team
Share this question
or