详细信息视图中的下拉列表,未列出项目
大家好
我有一个详细信息视图,其中有 3 个绑定字段和一个模板字段。
模板字段有一个 DropDownList,我已将其连接到 AccessDataSource。
但是当我运行时,下拉列表只有 "System.Data.DataRowView" 作为项目。
我希望将数据库中的项目列在 DropDownList
这是我的代码
asp:TemplateField HeaderText="State/Province" SortExpression="State/Province">
<EditItemTemplate>
<asp:DropDownList ID="ddlState" runat="server" DataSourceID="AccessDataSource1"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/db1.mdb"
SelectCommand="SELECT [State/Province_name] FROM [State/Province_List ]">
</asp:AccessDataSource>
</EditItemTemplate>
</asp:TemplateField>
我应该为 DropDownList 添加“DataBinding”或“DataBound”事件吗?使其完美?
帮我解决这个问题
谢谢, 阿琼
Hello Everyone
I have a detailsview, where there are 3 bound fields and a template field.
The template field has a DropDownList, which I have connected to an AccessDataSource.
But when I run, the dropdownlist has just the "System.Data.DataRowView" as it's items.
I wish to get the items from DB to be listed down in DropDownList
This is my code
asp:TemplateField HeaderText="State/Province" SortExpression="State/Province">
<EditItemTemplate>
<asp:DropDownList ID="ddlState" runat="server" DataSourceID="AccessDataSource1"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/db1.mdb"
SelectCommand="SELECT [State/Province_name] FROM [State/Province_List ]">
</asp:AccessDataSource>
</EditItemTemplate>
</asp:TemplateField>
Should I add "DataBinding" or "DataBound" event for DropDownList?? to make it perfect?
Help me regarding this issue
Thanks,
Arjun
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
定义要在下拉列表中使用的字段
如果您对此非标准列名称有问题,请尝试使用别名
(
[State/Province_List ]
中的空格可以吗?)然后使用此名称一
Define the filed to use in the drop down list
If you have problems with this non-standard column name, try to use an alias
(Is the space in
[State/Province_List ]
OK?)Then use this one