像Dropdown一样的文本框 [英] Textbox like Dropdown liast

查看:131
本文介绍了像Dropdown一样的文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Can I bind textbox like dropdownlist means in dropdownlist we can set datatextfield to show text and datavaluefield to insert value into database.

I have to do using textbox,I have added Autocomplete ajax toolkit extender to textbox. I am showing only Student Names but on click of button i have to insert SID of student not student name into the database.I search google they tell me use OnClientItemSelected of Autocomplete extender.How can i do any idea regarding this.

推荐答案

<body>
    <form id="form1" runat="server">
    <div>
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="SelectedIndexChanged">
            <asp:ListItem Value="Value 1" Text="Value 1" />
            <asp:ListItem Value="Value 2" Text="Value 2" />
            <asp:ListItem Value="Value 3" Text="Value 3" />
            <asp:ListItem Value="Value 4" Text="Value 4" />
            <asp:ListItem Value="Other" Text="Other" />
        </asp:DropDownList>


        <asp:TextBox ID="TextBox1" runat="server" />
    </div>
    </form>
</body>





public void SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList dropDownList = (DropDownList)sender;
            if (dropDownList.SelectedValue == "Other")
            {
                TextBox1.Enabled = true;
                TextBox1.Text = string.Empty;
            }
            else
            {
                TextBox1.Enabled = false;
                TextBox1.Text = dropDownList.SelectedValue;
            }
        }


您好,
美好的一天!!!

可编辑的下拉列表可能会帮助您满足您的要求
最好你试试这个.............

自定义ASP.NET可编辑DropDownList [
Hello ,
Good Day!!!

Editable Drop-down list may help you for your requirement
better you try this one .............

Custom ASP.NET Editable DropDownList[^]


这篇关于像Dropdown一样的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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