Click here to Skip to main content
15,042,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to bind data into textbox and dropdownlist.
Firstly, I insert data from textbox and dropdownlist.
I want to show data in dropdownlist as i inserted data when i retrieve data to textbox.
Posted
Comments
Tom Marvolo Riddle 24-Oct-13 1:14am
   
Sorry.Not clear
CodeBlack 24-Oct-13 1:25am
   
can you make your question more clear with code which you have tried ?

1 solution

from your question i only understood is you want to bind data to dropdownlist as soon as wrote data in TextBox.... correct me if i am wrong.
so based on what i understood m writing solution.

there is "onblur" event for textbox
onblur you can write javascript function to add new list in your dropdown list

JavaScript
function AddTextboxValueToDDL(sender)
{
var text=document.getElementById('<%= TxtData.ClientID %>').value;
var opt = document.createElement("option");
// Add an Option object to Drop Down/List Box
document.getElementById("ddllist").options.add(opt);
// Assign text and value to Option object
opt.text = text;
opt.value = text;
}

//and in your page there is textbox and dropdown list

<asp:textbox id="TxtData" onblur="AddTextboxValueToDDL(this);" runat="server" xmlns:asp="#unknown">
<asp:dropdownlist id="ddllist" runat="server" appenddatabounditems="true" />

</asp:textbox>
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900