我已经创建了一个启用了编辑的ListView,向导使用文本框生成了表,但我需要使用下拉列表来显示一些选项。
我已经创建了下拉列表
<asp:DropDownList ID="ActionStatusTextBox" runat="server">
<asp:ListItem Value="Ongoing">Ongoing</asp:ListItem>
<asp:ListItem Value="Open">Open</asp:ListItem>
<asp:ListItem Value="Closed">Closed</asp:ListItem>
</asp:DropDownList>下拉列表成功生成,但未提交并在数据库中输入自身。
<%# Bind("ActionStatus") %>'上面的代码片段需要在某个地方使用才能绑定数据,但是它需要附加到哪个参数才能传递数据?
我什么都试过了,真让我头疼!
谢谢
发布于 2011-01-18 22:08:45
你有没有尝试:
<asp:DropDownList .. SelectedValue='<%# Bind("ActionStatus") %>' />SelectedValue属性不会出现,但我相信您可以这样设置它。
HTH。
发布于 2011-02-13 01:42:06
您正在尝试向数据库中插入什么内容?如果手动添加列表标题,则不需要绑定任何内容。你可以直接
string value = ActionStatusTextBox.SelectedValue;发布于 2011-06-09 04:40:17
我也有同样的问题。看看这个帖子:Why is employee_id not being inserted into database
关键在于添加一个函数:
Protected Sub AbsentListView_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewInsertEventArgs) Handles AbsentListView.ItemInserting
e.Values("employee_id") = DirectCast(AbsentListView.InsertItem.FindControl("ExcusedAbsences_employee_idDropDownList2"), DropDownList).SelectedValue
End Sub它基本上是在需要的时候设置dropdown的值,一旦我这样做了,值就会进入数据库。
https://stackoverflow.com/questions/4724987
复制相似问题