Reputation: 43
I have a textbox and button. On button click, the data entered in the textbox is stored in the datatable, and this datatable bound to a gridview. Whenever I enter new data and click the button, the previously entered data is not displayed in the gridview.
How can I keep the data in the datatable on every button click?
Upvotes: 0
Views: 234
Reputation: 527
Call the method to get data in gridview again.
protected void Button1Click(object sender, EventArgs e)
{
GridView1.DataSource = data;
GridView1.DataBind();
}
Upvotes: 1
Reputation: 82136
Just call gridView.DataBind()
to refresh the data. If your add is causing a postback then you need to make sure you do it after the page has loaded.
Upvotes: 1