我们可以在静态方法中访问gridview吗? [英] can we access the gridview in static method?
本文介绍了我们可以在静态方法中访问gridview吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以用静态方法访问gridview吗?
如果是这样的话....
解决方案
< blockquote>是,如果您将gridview对象作为参数传递。
是,您可以在静态方法中访问gridview或任何ASP.NET控件,但您需要在参数的帮助下访问它喜欢以下方式。
方法声明 -
private static int GetData(GridView gridView)
{
//你可以随心所欲......
返回gridView.Rows.Count;
}
通话方式 -
GetData(gridViewName); //将网格作为参数传递
can we access the gridview in static method?
if so how....
解决方案
Yes if you pass the gridview object as a parameter.
Yes, You can access gridview or any ASP.NET control in static method but you need to access it with the help of Parameters like following way.
Method Declartion-
private static int GetData(GridView gridView)
{
//you can do whatever you want...
return gridView.Rows.Count;
}
Calling Method-
GetData(gridViewName);//pass grid as parameter
这篇关于我们可以在静态方法中访问gridview吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文