Reputation: 11
I have a gridview in an asp.net page, and get the data by binding it to a SQL Server Table, I use C# and Stored Procedure in SQL server to bind the data. every thing works fine,except when I Delete multiple rows by using Stored Procedure, the gridview still shows the old data. actually I have couple of text boxes that the user can enter the data and an asp button,as soon as user click the button, in code behind I call the Stored procedure and delete the data.
How could I Reload / Refresh the page? after deleting the rows?
Thanks in advance
Upvotes: 1
Views: 4038
Reputation: 50728
If you are using a datasource control (you supplied the datasourceid property), you have to call Grid.DataBind()
.
If you use the DataSource property of the grid, you have to reload the data source into that property from the database and call DataBind()
.
Upvotes: 4
Reputation: 12621
You could delete the rows in your datasource and rebind it to the grid to avoid retrieving data from the database again.
Upvotes: 0
Reputation: 22158
Just rebind your data to the gridview with another call to the database.
GridView1.DataSource = GetData(); //get your data with your original stored proc
GridView1.DataBind();
Upvotes: 3