I开发者_如何学编程 have an SQL Data Source which selects all rows of a table. I need to populate a dropdownlist with a certain field ('percentage') of all the rows, and when one is clicked to make the 'value' the rows 'id' field.
Is there a simple way of doing this? Thanks
You would want this:
<asp:DropDownList id="ddl_Items" runat="Server" DataTextField="percentage"
DataValueField="id" DataSourceId="sds_Items" />
<asp:SqlDataSource id="sds_Items" ...........other stuff........ />
You don't need to worry about assigning the value on click. Just do it when you load the DropDownList in the first place.
精彩评论