You must Sign In to post a response.
  • Category: ASP.NET

    Editable combo...... plz............

    I want editable dropdownlist in asp.net.
    is posible?
    pls help me.
    adv thanks to U.
  • #216258
    i hope this will help u.
    http://www.oreillynet.com/cs/user/view/cs_msg/26898



    Thanks & Regards
    G.Renganathan
    Nothing is mine ,Everything is yours!!!

  • #216332
    Hai

    here is the code


    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 EditabledrodownList : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    BindDataintoDrodownList();
    }
    }

    private void BindDataintoDrodownList()
    {
    DataTable dtpricelist = new DataTable();
    DataColumn col1 = new DataColumn("Name");
    DataColumn col2 = new DataColumn("Id");

    dtpricelist.Columns.Add(col1);
    dtpricelist.Columns.Add(col2);

    DataRow row7 = dtpricelist.NewRow();
    row7["Id"] = "2";
    row7["Name"] = "----New Item?----";
    dtpricelist.Rows.Add(row7);

    DataRow row1 = dtpricelist.NewRow();
    row1["Id"] ="3";
    row1["Name"] = "San";
    dtpricelist.Rows.Add(row1);

    DataRow row2 = dtpricelist.NewRow();
    row2["Id"] = "4";
    row2["Name"] = "Bala";
    dtpricelist.Rows.Add(row2);

    DataRow row3 = dtpricelist.NewRow();
    row3["Id"] = "5";
    row3["Name"] = "Siva";
    dtpricelist.Rows.Add(row3);

    dropdown.DataSource = dtpricelist;
    dropdown.DataBind();
    dropdown.SelectedIndex =1;
    }

    protected void dropdown_SelectedIndexChanged(object sender, EventArgs e)
    {

    if (this.dropdown.SelectedIndex == 0)
    {

    this.textbox.Text = "";
    this.dropdown.Visible = false;

    this.textbox.Visible = true;
    }

    }

    protected void textbox_TextChanged(object sender, EventArgs e)
    {

    int index = 0;if(!this.dropdown.Items.Contains(new ListItem(this.textbox.Text.Trim())))
    {

    this.dropdown.Items.Add(this.textbox.Text.Trim());
    }

    for (int i = 0; i < this.dropdown.Items.Count; i++)
    {

    if (dropdown.SelectedItem.Text == this.textbox.Text)
    {

    index = i;

    }

    }

    this.dropdown.SelectedIndex = index;
    this.dropdown.Visible = true;

    this.textbox.Visible = false;
    }


    }


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.