我正在尝试使用数据表更新下拉列表的来源。这似乎是成功调试后面的代码,但列表从未实际更新以显示绑定的项目。以下所有代码都在用户控件中,该用户控件在多视图中用作视图。多视图位于具有母版页文件的页面上。让我知道我做错了什么。
VB代码背后:
Public Sub GetSheetNames(strFilePathName As String)
Dim MyConnection As System.Data.OleDb.OleDbConnection
MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath(strFilePathName) + ";Extended Properties=Excel 12.0;")
Using (MyConnection)
MyConnection.Open()
Dim dt As DataTable = MyConnection.GetSchema("Tables")
Session("sessdtSheetNames") = dt
ddSheetName.DataSource = Session("sessdtSheetNames")
ddSheetName.DataValueField = "TABLE_NAME"
ddSheetName.DataTextField = "TABLE_NAME"
ddSheetName.DataBind()
End Using
upDD.Update()
End Sub
来自ASPX的下拉列表:
<asp:UpdatePanel ID="upDD" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="ddSheetName" runat="server" AutoPostBack="True" style="z-index: 1; left: 351px; top: 128px; position: absolute">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>