Home > ASP.Net > Bind DropdownList with Multiple Text Value

Bind DropdownList with Multiple Text Value


try this example :

let we have table in my database has the following fields (Id , Name , IsActive)

<asp: DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
    </asp: DropDownList>

in code behind:-

public void Bind()
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Bag_ConnStr"].ConnectionString);
        SqlCommand comm = new SqlCommand();
        comm.CommandText = "Select * from Education_Year";
        comm.Connection = conn;
        comm.CommandType = CommandType.Text;
        DataSet ds = new DataSet();
        SqlDataAdapter adapter = new SqlDataAdapter();
        adapter.SelectCommand = comm;
        if (ds.Tables[0].Rows.Count > 0)
            foreach (DataRow row in ds.Tables[0].Rows)
                ListItem ls = new ListItem();
                ls.Text = row["Name"] + " " + row["IsActive"];
                ls.Value = row["Id"].ToString();



    protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)

Good Luck

Categories: ASP.Net
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: