开发者

Refresh RadGridview when Insert,Update and Delete Operation done on Database in WPF

开发者 https://www.devze.com 2022-12-24 19:59 出处:网络
WPF and C#: Problem: 1. How to Refresh Radgridview when i Insert,update and Delete Record in database anrecord.

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;
        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 ........

my email address is patelriki13@gmail.com


one way is that you can call the function in which you are binding the datasource of gridview

the other way is that call the datasource again using stored procedure or linq and bind it again with that gridview.

calling function and binding datasource would be done in those button click which are used for insert,delete and update.

i think you just create a function and bind gridview in it and call it in page_load, after that call that function in insert,delete,update function after performing the desire task.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号