Hi, I have a verry common scenario:
An ASP.NET 2.0 Web App (AJAX Enabled) where the user must select some criteria's to view the results in a gridview.
In this case it's a Company with multiple Vehicles possible. For each vehicle you can see some actions/registrations in a Gridview or DataList.
You have a DropDownList for selecting the company,
and another one for selecting the vehicles.
As the page Loads for the first time I want to load all possible companies in the first DropDownList. And because the first company in the list is selected I want to load all it's vehicles in the second DropDownList. until here: not difficult:
Code:
if (!IsPostBack && !IsCallback)
{
//Load All Companies
_companies = Company.GetAllVersions();
foreach (CompanyInfo company in _companies)
{
_ddCompany.Items.Add(new ListItem(company.Name + " (" + company.Version.ToString() + ")", company.Id.ToString()));
}
if (_ddCompany.SelectedValue != null)
{
_vehicles = Vehicle.GetByCompanyId(new Guid(_ddCompany.SelectedValue));
foreach (VehicleInfo vehicle in _vehicles)
{
_ddUnits.Items.Add(new ListItem(vehicle.Name + "-" + vehicle.UnitId, vehicle.UnitId.ToString()));
}
}
The problem is when you change the company the list of Vehicle should load automaticly with the vehicles of that newly selected company, in preference not the rest of the page.
I tried the '_ddCompany_SelectedIndexChanged' but this event only get's fired after a postback. (Should I use updatepanel or PostBack Events with querrystrings, and with updatepanels: should I seperate the controls in different updatepanels or should I group some controls together in fewer updatepanels? wich one (2 dropdowns, some other selectioncriteriacontrols, and a list (eg DataList or Gridview)?)
It's too common problem for not already being solved. Can anyone point me the right direction?
Now I'm looking for the best way (most effective, fastest, most changeable) solution to do this but I didn't find anything usefull on Google and forums.
Thx guys