using System;
using System.Data;
using System.Configuration;
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 _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        index1.Text = DropDownList1.SelectedIndex.ToString();//this coe is writen to display defaut item of dropdown
        text1.Text = DropDownList1.SelectedItem.Text;//remove this code and see the result
        value1.Text = DropDownList1.SelectedValue;//
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        index1.Text = DropDownList1.SelectedIndex.ToString();
        text1.Text = DropDownList1.SelectedItem.Text;
        value1.Text = DropDownList1.SelectedValue;
       }
    protected void Button1_Click(object sender, EventArgs e)
    {
        DropDownList1.Items.RemoveAt(Convert.ToInt16(DropDownList1.SelectedIndex.ToString()));
   
        /* these button do nothing but kept fort autopostback as to display content in
         DropDownList1_SelectedIndexChanged as these need postback to do so;
        IMP--> Inorder not to INCLUDE button make AutoPostBack property of drpp true
        */
    }
}

Like it on Facebook, Tweet it or share this article on other bookmarking websites.

No comments