如何使用下拉列表值填充文本框? [英] How to populate textbox with Dropdown list value?

查看:94
本文介绍了如何使用下拉列表值填充文本框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个不受数据限制的DDL。它由一系列我可供用户选择的内容组成。我试图将这个值填充到文本框中。我该怎么做?



I have a DDL that is not data bound. It is made up with a list of things I have for the user to choose from. I am trying to get that value to populate into a textbox. How would I do this?

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
                   onselectedindexchanged="DropDownList1_SelectedIndexChanged" Width="150px">
                   <asp:ListItem>Select Calendar</asp:ListItem>
                   <asp:ListItem>Semester</asp:ListItem>
                   <asp:ListItem>Quarter</asp:ListItem>
               </asp:DropDownList>





代码背后



Code Behind

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //TextBoxCal.Text = ["Calendar"].ToString();
        }

推荐答案

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
    TextBoxCal.Text = DropDownList1.SelectedValue;
}


这篇关于如何使用下拉列表值填充文本框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆