G
Guest
I have a dropdownlist which will jump to another page when selection change.
The onChange handler is done by JavaScript rather than setting AutoPostBack
to true. ViewState is disabled since the page do not post back to itself.
In the Page_onLoad, the DropDownList bind to datasource and databind() is
called.
After that, I want to hardcode the SelectedIndex however it doesn't work.
//code in Page_onLoad
DataView dv = dt.DefaultView;
dv.Sort = "Date DESC";
DDL.DataSource = dv;
DDL.DataTextField = "date";
DDL.DataValueField = "url";
DDL.DataBind();
DDL.SelectedIndex = 2; // <- doen't work
the DDL always select the first option
The onChange handler is done by JavaScript rather than setting AutoPostBack
to true. ViewState is disabled since the page do not post back to itself.
In the Page_onLoad, the DropDownList bind to datasource and databind() is
called.
After that, I want to hardcode the SelectedIndex however it doesn't work.
//code in Page_onLoad
DataView dv = dt.DefaultView;
dv.Sort = "Date DESC";
DDL.DataSource = dv;
DDL.DataTextField = "date";
DDL.DataValueField = "url";
DDL.DataBind();
DDL.SelectedIndex = 2; // <- doen't work
the DDL always select the first option