开发者

Make a TextBox sync with SelectedValue of a DropDownList

开发者 https://www.devze.com 2022-12-19 00:58 出处:网络
I have a FormView with the following ItemTemplate.What do I have to do to make the Textbox reflect the correct TypeName for the selected campaign?

I have a FormView with the following ItemTemplate. What do I have to do to make the Textbox reflect the correct TypeName for the selected campaign?

<asp:Label ID="campaignNameLabel" runat="server" AssociatedControlID="campaignList">Campaign Name: </asp:Label>
<asp:DropDownList ID="campaignList" runat="server" Width="200px" AutoPostBack="True" DataSourceID="campaignsSqlDataSource" DataValueField="CampaignID" DataTextField="Name" SelectedValue='<%# Bind("CampaignID") %>'>
</asp:DropDownList>
<asp:Label ID="campaignTypeLabel" runat="server">Campaign Type: </asp:Label>
<asp:TextBox ID="campaignTypeText" runat="server" Width="150px" Text='<%# Eval("TypeName") %>'></asp:TextBox>

ADDENDUM: I'm trying to do this with zero code. I can make it work if I use a separate data source for the drop-down and the detail fields in the ItemTemplate (i.e. the FormView's main data source), but I can't sync the FormView's data source with the drop-down's selection, because a ControlParameter on the FormView data source can't see control values开发者_如何学Python in the ItemTemplate.


@Jan's answer is for doing it server side, if you are looking to do it client side check this post: -One dropdownlist currency converter-

0

精彩评论

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