如何访问asp.net控件,如gridview,asp.net中的静态方法下拉? [英] how to access asp.net controls like gridview,dropdown in static method in asp.net ?

查看:65
本文介绍了如何访问asp.net控件,如gridview,asp.net中的静态方法下拉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i希望以静态方法访问gridview,但我无法访问它,所以任何人都有任何想法然后plz帮我解决这个问题



例如。让我在我的页面中有一个gridview(gridview1)和一个按钮(button1)。现在我有一个静态方法,即LoadGV



public static LoadGV()

{

gridview1.Datasource = SomeData;

gridview1.DataBind();

}

按钮点击
我想打电话给这个方法。





提前thnx


i want to access gridview in a static method but i m not able to access it so any one have any idea then plz help me to solve this problem

Eg. let i hv a gridview(gridview1) and a button(button1) in my page.now i have a static method i.e LoadGV

public static LoadGV()
{
gridview1.Datasource=SomeData;
gridview1.DataBind();
}

in button click i want to call this method.


Thnx in advance

推荐答案

你不能这样做。静态方法仅适用于静态属性和属性。 gridview1是GridView类的一个对象,所以静态方法无法调用它!



尝试删除关键字静态。 />


希望它有助于解释你的情况。
You cannot do that. Static methods only works with static attributes and properties. gridview1 is an object of the GridView class, so the static method cannot call it!

Try to remove the key word static.

Hope it helps and explain your scenario.


你是白痴,给出解决方案没有任何意义。
you idiot, giving solutions does not make any sense.


这篇关于如何访问asp.net控件,如gridview,asp.net中的静态方法下拉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆