i have this code
DataTable dt = new DataTable("MyDataTable");
dt.Columns.Add("Value1");
dt.Columns.Add("Value2");
dt.Columns.Add("Value3");
dt.Rows.Add(TextBox1.Text, TextBox2.Text, TextBox3.Text);
GridView1.DataSource = dt;
GridView1.DataBind();
When i try inserting data to a gridview using this code the new values replace with the old values. how can i develop this to add new records without replacing.
You’re rebinding your gridview. This will wipe the existing data. If you want to update your grid view I’d suggest adding the new row to a persistent data store and refreshing from that. This could be a database table or data structure.