I have an ASP.NET web form on which I use the DropDownList control so that the user can select the item and see the related results. For some reason, when I set the SelectedValue property to DropDownList, the value it set is not immediately available.
Here is my code:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DropDownList1.SelectedValue = "5";
BindView();
}
}
protected void BindActivities()
{
DataClassesDataContext dc = new DataClassesDataContext();
var query = from activity in dc.Activities
where activity.AssignedTo == Convert.ToInt32(DropDownList1.SelectedValue);
GridView1.DataSource = query;
GridView1.DataBind();
}
, DropDownList1.SelectedValue NULL. , , DropDownList1.SelectedValue , DropDownList1 5. , , , . , DropDownList.SelectedValue 5 , .
, ?