Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting DropDownList Value from ListView InsertItemTemlate

Status
Not open for further replies.

stinkybee

Programmer
May 15, 2001
218
GB
Is there a way to get the value from a DropDownList into the InsertParameters of a ListView SqlDataSource. I know that Bind() and Eval() don't work even though this works for other elements like TextBox.

For example

Code:
<asp:DropDownList ID="voucher_type_idDropDownList" runat="server" DataSourceID="SqlDataSourceVoucherType" DataTextField="voucher_type_name" DataValueField="voucher_type_id" EnableViewState="true" AppendDataBoundItems="True" SelectedValue='<%# Bind("voucher_type_id")%>'>
<asp:ListItem Selected="True" Value="0" Text="Select Voucher Type"></asp:ListItem>
</asp:DropDownList>

throws an error

So is there a way to do this in a similar way that you would for a TextBox?

Failing that, what code would I need to access this value and add it to my ListView data source InsertParameters?

In case you are wondering, I have been searching all day for an answer but as yet have not found anything.

Thanks in advance for any help.

Web Development Manager
 
I have no idea how to do this in the markup as I never user the datasource controls. I am very against them for just this reason. Whenever you need to do something a bit differently or more complicated, they just become a PITA.
You should just simply set the value of the parameter in the code behind of the SQLDataSource. Use the Selecting event.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top