Drodpownlist1不在intellisense列表中 [英] Drodpownlist1 is not in intellisense list

查看:88
本文介绍了Drodpownlist1不在intellisense列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着打电话给dropdownlist1,但这不在列表中。



i尝试做这样的事情



函数是静态的

i try to call dropdownlist1 but this is not available in list

i try to do something this like this

function is in static

[WebMethod]
       public static string Jqufunc(int yearP,int )
       {





我尝试过:





What I have tried:

if ((Dropdownlist1.selectvalue) != 0)
                {
                    con = con.Where(c => c.CustName.Contains(Dropdownlist1.selectvalue) || c.InvoiceID == Dropdownlist1.selectvalue);
                }





但Dropdownlist1不在列表中

< asp:DropDownList ID = DropDownList1runat =server

onselectedindexchanged =DropDownList1_SelectedIndexChanged>



but Dropdownlist1 is not in list
<asp:DropDownList ID="DropDownList1" runat="server"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">

推荐答案

静态方法无法访问非静态类信息,意味着你的方法中没有任何控件作为表格的一部分。

静态方法没有这个引用当前实例类的 - 这就是 static 意味着,它不依赖于任何特定的实例,而是通用于整个类 - 因此无法访问任何实例。



如果你喜欢,它就像一辆汽车:汽车的一个例子有一种颜色:因为你不能说车是什么颜色的?但你必须指明哪辆车这辆车是什么颜色的?,那车是什么颜色的?,我的车是什么颜色的?等等。 颜色是汽车的一个实例属性。

但是所有汽车都有四个轮子,所以你可以说车有多少轮子?无需指定特定实例。 WheelCount是汽车的静态属性。



在您的情况下,您可以使方法非静态,或将控件从实例传递给它。你不能直接访问任何控件。
Static methods cannot access non-static class information, which means that any controls which are part of the form are unavailable within your method.
Static methods do not have a this which refers to the current instance of the class - that's what static means, it isn't dependant on any particular instance but general to the whole class - and so can't access anything which does.

If you like, it's like a car: an instance of a car has a colour: because you can't say "what colour is a car?" but you have to specify which car "what colour is this car?", "what colour is that car?", "what colour is my car?" and so forth. "Colour" is an instance property of a car.
But all cars have four wheels, so you can say "how many wheels has a car?" without having to specify a particular instance. "WheelCount" is a static property of a car.

In your case, you could make the method non-static, or pass the control to it from the instance. You can't access any control directly.


检查这个



c# - 如何在ASP.net中的静态方法内访问页面控件 - Stack Overflow [ ^ ]

从静态方法访问控件 [ ^ ]
Check this

c# - How to acess page controls inside a static method in ASP.net - Stack Overflow[^]
Accessing controls from Static method[^]


这篇关于Drodpownlist1不在intellisense列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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