'selCurrentManuf' is not declared. It may be inaccessible due to its protection level [closed]
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;
精彩评论