dropdownlist custom databinding
DropDownList inside Gridview.
Database Schema:
Restaurants Menus Products
RestaurantID MenuID ProductID
RestaurantName MenuName ProductName
RestaurantID MenuID
it doesnt work with this:
<asp:DropDownList ID="DropDownList8" runat="server" DataSourceID="ObjectDataSource3"
SelectedValue='<%# Bind("MenuID") %>' DataTextField="RestaurantName" DataValueField="RestaurantID">
Gridview has GetAllProducts method.
ObjectDataSource3 has GetAllRestaur开发者_StackOverflow社区ants method.
I want to edit and insert Menus of each Product. But I want to show RestaurantName indtead of MenuID..
When you want to bind Questions and Categories (just two) tables, this can work easily:
<asp:DropDownList ID="DropDownList8" runat="server" DataSourceID="ObjectDataSource3" SelectedValue='<%# Bind("CategoryID") %>' DataTextField="CategoryName" DataValueField="CategoryID">
I have 3 tables to reach data.. How can I do this?
Thanks
Dropdownlist has a Property DataTextField for this purpose.
<asp:DropDownList ID="DropDownList8" runat="server" DataSourceID="ObjectDataSource3"
SelectedValue='<%# Bind("MenuID") %>' DataTextField="RestaurantName" DataValueField="RestaurantID">
精彩评论