开发者

'selCurrentManuf' is not declared. It may be inaccessible due to its protection level [closed]

开发者 https://www.devze.com 2023-04-10 23:12 出处:网络
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is not generally applic
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.

i have a drop down list i am trying to use the id of in a sql in the code behind but i get error...

is not declared. It may be inaccessible due to its protection level.

  <asp:DropDownList  
  selectedvalue='<%#Container.DataItem("manufidcurrent")%>' 
  ID="selCurrentManuf" 
  Runat="Server" 
  DataTextField="Desc" 
  DataValueField="manufid"
  DataSource="<%# GetCurrentManuf() %>" 
  autopostback="true" 
  OnSelectedIndexChanged="selCurrentManuf_SelectedIndexChanged"  ></asp:DropDownList>

In the code behind i have a function trying to use the selected option...

Function GetCurrentModel() As DataSet
Dim mySession = System.Web.HttpContext.Current.Session
Dim myQuery As String = "SELECT * FROM model where id = " + selCurrentManuf.SelectedI开发者_如何学JAVAtem.Value
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, "model")
Dim dr As DataRow = myDataset.Tables(0).NewRow       
myDataset.Tables(0).Rows.Add(dr)      
GetCurrentModel =  myDataset             
End Function


Sometimes the designer.cs file gets screwed up. You can add the DropDown to the designer.cs file manually, or cutting and pasting the dropdown into the markup again may correct the problem.

To declare the DropDown manually in the designer.cs file:

/// <summary>
/// selCurrentManuf control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.DropDownList selCurrentManuf;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号