开发者

Gridview Refresh Problem

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


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().


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();


You could delete the rows in your datasource and rebind it to the grid to avoid retrieving data from the database again.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜