开发者

dropdownlist custom databinding

开发者 https://www.devze.com 2023-01-02 18:42 出处:网络
DropDownList inside Gridview. Database Schema: RestaurantsMenusProducts RestaurantIDMenuIDProductID RestaurantNameMenuNameProductName

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">
0

精彩评论

暂无评论...
验证码 换一张
取 消