Dropdownlist problem
-
I have a problem with textbox and dropdownlist. My form contains ddl's,txt's and some other controls. On the pageload i am filling dropdown with some list. While Inserting values into database, for example,i am using a dropdownlist only for display.If i want to add some data of that dropdownlist kind,i am using textbox. The requirement is If i enter some text,it shd check in the dropdownlist.If it has the same value,it should focus on the dropdownlist value,so that user can select it.It will come into the textbox. This i want when he is trying to add some value(Not on the button click event,keyboard press time.).It should check from the dropdownlist values. Plese try to understand and solve my little problem. THanks in advnace. I am using asp.net 1.1,with sqlsever2000. REgards
kissy
-
I have a problem with textbox and dropdownlist. My form contains ddl's,txt's and some other controls. On the pageload i am filling dropdown with some list. While Inserting values into database, for example,i am using a dropdownlist only for display.If i want to add some data of that dropdownlist kind,i am using textbox. The requirement is If i enter some text,it shd check in the dropdownlist.If it has the same value,it should focus on the dropdownlist value,so that user can select it.It will come into the textbox. This i want when he is trying to add some value(Not on the button click event,keyboard press time.).It should check from the dropdownlist values. Plese try to understand and solve my little problem. THanks in advnace. I am using asp.net 1.1,with sqlsever2000. REgards
kissy
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class ClientCallback : System.Web.UI.Page, System.Web.UI.ICallbackEventHandler { protected System.Collections.Specialized.ListDictionary catalog; protected String returnValue; protected void Page_Load(object sender, EventArgs e) { String cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context"); String callbackScript; callbackScript = "function CallServer(arg, context)" + "{ " + cbReference + ";}"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true); if(!Page.IsPostBack) { ddstate.DataSource = objnewdoc.fillddstate(); ddstate.DataValueField = objnewdoc.fillddstate().Tables[0].Columns[0].ToString(); ddstate.DataTextField = objnewdoc.fillddstate().Tables[0].Columns[1].ToString(); ddstate.DataBind(); ddstate.Items.Capacity = ddstate.Items.Capacity + 1; ListItem lt = new ListItem(); lt.Text = "<-Select State->"; lt.Value = "0"; ddstate.Items.Insert(0, lt); ListItem ltcity = new ListItem(); ltcity.Text = "<-Select->"; ltcity.Value = "0"; ddcity.Items.Insert(0, ltcity); } //catalog = new System.Collections.Specialized.ListDictionary(); //catalog.Add("monitor", 12); //catalog.Add("laptop", 10); //catalog.Add("keyboard", 23); //catalog.Add("mouse", 17); //ListBox1.DataSource = catalog; //ListBox1.DataTextField = "key"; //ListBox1.DataBind(); } public void RaiseCallbackEvent(String eventArgument) { if (catalog[eventArgument] == null) { returnValue = "-1"; } else { DataSet dsCity = objnewdoc.GetCityID(eventArgument); returnValue = dsCity.Tables[0].Rows[0][0].ToString(); for (int cnt = 1; cnt < dsCity.Tables[0].Rows.Count; cnt++) { returnValue = returnValue + "," + dsCity.Tables[0].Row
-
I have a problem with textbox and dropdownlist. My form contains ddl's,txt's and some other controls. On the pageload i am filling dropdown with some list. While Inserting values into database, for example,i am using a dropdownlist only for display.If i want to add some data of that dropdownlist kind,i am using textbox. The requirement is If i enter some text,it shd check in the dropdownlist.If it has the same value,it should focus on the dropdownlist value,so that user can select it.It will come into the textbox. This i want when he is trying to add some value(Not on the button click event,keyboard press time.).It should check from the dropdownlist values. Plese try to understand and solve my little problem. THanks in advnace. I am using asp.net 1.1,with sqlsever2000. REgards
kissy
Hi, If I am not wrong you want to check whether the value you are entering in textbox already exist in DropDown ? Well U can extensively use JavaScript for this purpose, On KeyPress event of the TextBox Compare the Value in TextBox with DropDownList options if it matches any Value of DropDownList using substring method (ie if Text in the Textbox is found to be the Substring of any existing value of DropDownList Set that option as selected ) This should be the approach according to me. Give me a Day or 2 iwill try to implement it myself :cool: