Home > DeveloperSection > Forums > How to refresh gridview after every insert command automatically?
Pravesh Singh
Pravesh Singh

Total Post:101

Posted on    August-28-2014 1:34 AM


 1 Reply(s)
 830  View(s)
Rate this:

I am inserting data to database when i click submit button data inserted into Database but no changes get reflected in GridView without refreshing the page.

Sumit Kesarwani

Total Post:378

Posted on    August-28-2014 2:21 AM

Hi Pravesh, 

public void GetData()       




            SqlConnection connection = new SqlConnection();

            connection.ConnectionString = ConfigurationManager.ConnectionStrings["mysql"].ConnectionString;

            String sql = "Your Query";

            DataSet ds = new DataSet();

            SqlDataAdapter da = new SqlDataAdapter(sql, connection);


            DataTable dt = new DataTable();

            dt = ds.Tables[0];

            GridView1.DataSource = dt;


        catch (SqlException ex)



        catch (Exception e)




Don't want to miss updates? Please click the below button!

Follow MindStick