Skip to main content
 首页 » 编程设计

c#之在 VS 2010 asp.net 中没有获取 gridview1.Rows.Clear() 选项

2024年02月20日13over140

<分区>

Possible Duplicate:
How can I clear rows in DataGridView with C#?

我正在使用 gridview 来显示我的一些数据的详细信息。流程是这样的:当一个下拉值改变时,gridview中的数据会根据选择的值进行绑定(bind)。现在当没有对应于该值的数据时,我需要清除 gridview。为此,我使用:

gridview1.Rows.Clear() 

但是当我编译我的代码时,产生了一个错误:

System.Web.UI.WebControls.GridViewRowCollection' does not contain a definition for 
'Clear' and no extension method 'Clear' accepting a first argument of type 
'System.Web.UI.WebControls.GridViewRowCollection' could be found (are you missing 
a using directive or an assembly reference?) 

我也给出了引用:

using System.Web.UI.WebControls; 

现在我应该如何清除gridview?

提前致谢。