Hi,
I've been asked to create a page that dynamically populates the contents of
related drop down lists using JavaScript, and then obviously posts things
back to the server.
For completeness, I re-produce example JavaScript below (this seemingly
works fine - but just to let you see what is going on)
e.g. var categoriesArray = TrendCategoriesHolder[intTrendIndex];
for ( i = 0; i <= categoriesArray.length - 1; i++)
{ var categoriesObject = categoriesArray[i];
var categoriesText = categoriesObject[0];
var categoriesValue = categoriesObject[2];
ddlTrendCategory.options[i] = new Option(categoriesText,
categoriesValue);
}
var ddlTrendType = document.getElementById("ddlTrendType");
ddlTrendCategory.options[ddlTrendCategory.options.length] = new
Option("All Categories", 0);
When I post this back to the server, if i use
ddlTrendCategory.SelectedValue.ToString() it claims it evalutates to "". If i
use ddlTrendCategory.SelectedItem.Value.ToString() then it errors, with a
null reference error.
So, seemingly ASP.NET is not recognising that the drop down list has
contents. Is there a way round this, or is the whole approach I was asked to
do invalid and doomed to fail!
Help appreciated. Thanks in avance.