简体   繁体   English

未声明下拉列表。 由于其保护级别,它可能无法访问

[英]dropdownlist is not declared. It may be inaccessible due to its protection level

As you can see from the commented out code, I'm trying to get the model dropdown be affected by + selCurrentManuf.Text . 从注释掉的代码中可以看出,我试图让模型下拉列表受到+ selCurrentManuf.Text影响。

I get this error 我收到这个错误

'selCurrentManuf' is not declared. 'selCurrentManuf'未声明。 It may be inaccessible due to its protection level. 由于其保护级别,它可能无法访问。

How can this be solved? 怎么解决这个问题?

I can access the drop down in another part of the page like this.. 我可以像这样访问页面另一部分的下拉菜单。

Dim sc1_currentmanuf As String = CType(e.Item.FindControl("selCurrentManuf"), DropDownList).Text

However in the function i am trying to use selCurrentManuf does not have access to e 但是在我尝试使用的函数中,selCurrentManuf无法访问e

Right click on your .aspx page, and select the command Convert To Web Application. 右键单击.aspx页面,然后选择“转换为Web应用程序”命令。

Then you'll be able to write: 然后你就可以写:

  Dim myQuery As String = 
    String.Format("SELECT * FROM c5_model WHERE c5_manuf = '{0}'", 
                  selCurrentManuf.SelectedItem.Text )
    Dim sc1_currentmanuf As String = CType(dlContacts.Items(0).FindControl("selCurrentManuf"), DropDownList).Text
    Dim myQuery As String = "SELECT * FROM c5_model where c5_manufid = " + sc1_currentmanuf

I'm assuming your functions are inside a class in your App_Code or another dll and not on the code behind of the page. 我假设你的函数在你的App_Code或另一个dll中的一个类中,而不是在页面后面的代码中。

If so do this instead: 如果是这样,请改为:

I'm assuming you have something like this on your asp page code behind: 我假设你的asp页面代码背后有这样的东西:

Protected Sub selCurrentManuf_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        GetCurrentModel(selCurrentManuf.Text)
End Sub

Change Your GetCurrentModel Code To: 将GetCurrentModel代码更改为:

Function GetCurrentModel(Byval c5_manuf as String) As DataSet
    Dim mySession = System.Web.HttpContext.Current.Session
    Dim myQuery As String = "SELECT * FROM c5_model " 'where c5_manuf = " + + c5_manuf 
    Dim myConnection As New MySqlConnection(mySession("localConn"))
    myConnection.Open()
    Dim myCommand As New MySqlCommand(myQuery, myConnection)
    Dim myDataAdapter = New MySqlDataAdapter(myCommand)
    Dim myDataset As New DataSet
    myDataAdapter.Fill(myDataset, "c5_model")
    Dim dr As DataRow = myDataset.Tables(0).NewRow       
    myDataset.Tables(0).Rows.Add(dr)      
    GetCurrentModel =  myDataset
    myConnection.Close()         
 End Function

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未声明“ ZoneDropDown”。 由于其保护级别,它可能无法访问 - 'ZoneDropDown' is not declared. It may be inaccessible due to its protection level 未声明控制权。 由于其保护级别,它可能无法访问 - Control is not declared. It may be inaccessible due to its protection level 'ViewBag'未声明。 由于其保护级别,它可能无法访问 - 'ViewBag' is not declared. It may be inaccessible due to its protection level 'txtName' 未声明。 由于其保护级别,它可能无法访问 - 'txtName' is not declared. It may be inaccessible due to its protection level BC30451:未声明'NewsBody'。 由于其保护级别,它可能无法访问 - BC30451: 'NewsBody' is not declared. It may be inaccessible due to its protection level (VB.NET)未声明“ VB6”。 由于其保护级别,它可能无法访问 - (VB.NET) 'VB6' is not declared. It may be inaccessible due to its protection level BC30451:未声明'MailValidation'。 由于其保护级别,它可能无法访问 - BC30451: 'MailValidation' is not declared. It may be inaccessible due to its protection level 我收到“未声明'Eval'。 由于它的保护级别,它可能无法访问。 - I'm getting “'Eval' is not declared. It may be inaccessible due to its protection level” in a ascx 添加的asp控件给出错误'未声明。 由于其保护级别,它可能无法访问。 - added asp control gives error 'is not declared. It may be inaccessible due to its protection level.' Asp.net成员资格配置文件的名字和姓氏(未声明。由于其保护级别,可能无法访问) - Asp.net Membership Profile FirstName and LastName (Not declared. It may be inaccessible due to its protection level )
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM