views:

322

answers:

2

In a ASP .NET 3.5 ListView InsertItemTemplate I would like to change a textbox:

<asp:TextBox ID="txt" runat="server" Text='<%# Bind("plant") %>' />

to a ListBox:

<asp:ListBox ID="list" runat="server" DataValueField='<%# Bind("plant") %>' >

How do I bind the field 'plant' to the listbox?

UPDATE 1

Here is a sample of using a combobox with the SelectedValue property:

<cc1:ComboBox ID="ComboBox1" AutoPostBack="false" 
     DropDownStyle="DropDownList" AutoCompleteMode="Suggest" 
     CaseSensitive="false" CssClass="AjaxToolkitStyle" 
     ItemInsertLocation="Append" 
     SelectedValue='<%# Bind("car") %>' runat="server">
   <asp:ListItem>Porsche</asp:ListItem>
   <asp:ListItem>VW</asp:ListItem>
   <asp:ListItem>BMW</asp:ListItem>
   <asp:ListItem>UNK</asp:ListItem>
</cc1:ComboBox>
+1  A: 

have you tried SelectedValue?

<asp:ListBox ID="list" runat="server" SelectedValue='<%# Bind("plant") %>' >
</asp:ListBox>
Scott Ivey
Is SelectedValue a valid property? It doesn't show up in the IntelliSense autocomplete.
John M
It doesn't show up in the intellisense in markup - but it is valid. Same goes for DropDownList.
Scott Ivey
+1  A: 
<asp:ListBox ID="list" runat="server">
    <asp:ListItem Text='<%# Bind("plant") %>'></asp:ListItem>
</asp:ListBox>

However, this will just populate the listbox with the one item, which I doubt is what you want.

Jason Berkan