Reputation: 91
I tried below code in Page_Init() but i am getting null values. How to get Dropdownlist selected values in Page_Init().
protected void Page_Init(object sender, EventArgs e)
{
string test1 = Request.Form[ddlProjectResource.Text];
string test2 = Request.Form[ddlProjectResource.SelectedValue];
}
Upvotes: 1
Views: 948
Reputation: 21
This will give you the SelectedValue of ddlProjectResource:
Request.Form[ddlProjectResource.UniqueID];
If you list is not populated from an external data-source then you should be able to use:
(DropDownList)page.FindControl(ddlProjectResource.UniqueID).SelectedItem;
Saying that the first solution is more performant as it only has to scan through the collection of values in the Form collection instead of scan through the whole html page.
Upvotes: 1