Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Jul 20, 2022, 2:21 AM EDT
Shivam PayasiRank #602 · 4K reputationPosted Jul 20, 2022, 2:23 AM EDT
Hello, Manju Jd I think you are performing some insert or update operation on the data table after that you want to see the updated DataGridView.
now you need to create a method Named LoadData() or RefreshGrid() whatever you want it's your choice
and this method contains code
private void RefreshGrid()
{
con = db.connection();//Here you can simply add your connection
con.Open();
SqlDataAdapter sd = new SqlDataAdapter("select *from TblDept",con);//write your Query to get data
dataGridView1.DataSource = null;//this is the main Part Here you need to clean all data that was presented in the Grid
DataSet ds = new DataSet();
sd.Fill(ds, "TblDept");
dataGridView1.DataSource = ds.Tables[0];//Now here we are Reloading the Gtrid
}
Here in this method we are removing all Old data from GridView and Adding Updated data on the Grid You can use your
own code to load data on GridView Important part is to remove All data from the grid by
dataGridView1.DataSource = null;
and Reload GridView With your Data
you just need to call this method whenever you need to Refresh the GridView it will work.
Thanks.. for Your Query
Amit MohantyRank #112 · 20K reputationPosted Jul 20, 2022, 1:03 AM EDT
Vishal YelveRank #178 · 13.6K reputationPosted Jul 19, 2022, 3:16 PM EDT