---
title: "how to take the immideately selected value of Dropdownlist?"  
description: "how to take the immideately selected value of Dropdownlist?"  
author: "Allen Scott"  
published: 2014-12-21  
updated: 2014-12-22  
canonical: https://www.mindstick.com/forum/12801/how-to-take-the-immideately-selected-value-of-dropdownlist  
category: "asp.net"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# how to take the immideately selected value of Dropdownlist?

i have 2 drop downs where both of them are having auto [postback](https://www.mindstick.com/blog/342/postback-in-asp-dot-net) true. while i [select](https://www.mindstick.com/forum/160534/orderby-then-select-vs-select-then-orderby-performance) from the dropdown1 it sends dropdown2 a id and the dropdown2 shows data corresponding that id. but the [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) is it is not showing when the page starts for the first time,and its always showing the [previous](https://yourviews.mindstick.com/view/81421/unlock-2-0-is-just-like-previous-corona-lockdowns) [selected items](https://www.mindstick.com/forum/352/i-need-to-display-my-checkboxlist-selected-items-in-a-label-how-to-do) value.

like when the page is loaded its selecting "sayd" in dropdown1 automatically.and for that its selecting the corresponding name in the other dropdown2.but when i am [starting](https://www.mindstick.com/blog/12024/things-you-need-to-know-when-starting-your-own-business) the [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) its not showing the [selected value](https://www.mindstick.com/forum/525/get-selected-value-of-datagridviewcomboboxcolumn) for the [default](https://www.mindstick.com/interview/12771/what-is-the-importance-of-default-resources) one.and when i am selecting manually.its showing the previous selected value.

i dont know why its happening and what is the [solutions](https://www.mindstick.com/articles/12807/product-searching-issues-and-solutions-for-ecommerce-store-advanced-search-autocomplete-suggest) for that any one can suggest please?

```
protected void Page_Load(object sender, EventArgs e){      if (!Page.IsPostBack)      {            ddwcategory.DataBind();            ddwsubcat.DataBind();     }     else      {           if (ddwsubcat.Items.Count <= 1)           {                 ddwsubcat.SelectedIndex = -1;                 ddwsubcat.DataBind();           }            Label1.Text = ddwsubcat.SelectedValue;     }}
```

## Replies

### Reply by Anonymous User

hat thing did work.

```
if (!Page.IsPostBack)    {        
ddwcategory.DataBind();       
ddwsubcat.DataBind();     }    else    {        if(ddwsubcat.Items.Count <= 1)        {           
ddwsubcat.SelectedIndex = -1;           
ddwsubcat.DataBind();        }      //  Label1.Text = ddwsubcat.SelectedValue;       
//ddwsubcat.DataBind();    }    String subcat =ddwsubcat.SelectedValue;
```

### Reply by Anonymous User

Some of your code was outside !PostBack condition.

```
protected void Page_Load(object sender, EventArgs e){      if (!Page.IsPostBack)      {           // Bind your dropdownlists on page Load event          ddwcategory.DataBind();           ddwsubcat.DataBind();          // Set default index if required           Label1.Text = ddwsubcat.SelectedValue;     }}
```


---

Original Source: https://www.mindstick.com/forum/12801/how-to-take-the-immideately-selected-value-of-dropdownlist

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
