I've tried that too..
my code is as follows (BindData() gets called from the Page_Load method):
private void BindData()
{
lstAssociations.DataSource =
BusinessLogic.ProductAssociations.Instance().GetAs sociations();
lstAssociations.DataTextField = "DisplayText";
lstAssociations.DataValueField = "AssociationID";
lstAssociations.DataBind();
lstAssociations.SelectedValue = Request.QueryString["associationID"];
// Also tried
//
lstAssociations.Items.FindByValue(Request["associationID"].ToString().Trim()
).Selected = true;
}
Any ideas?
"Giri" <gt******@prologis.com> wrote in message
news:OQ**************@TK2MSFTNGP11.phx.gbl...
try using the FindByValue method on the items collection and then set the
Selected property to true:
ddlMyList.Items.FindByValue("stringforselectedvalu e").Selected = true;
hth
"Steven" <ms******@berkovitz.org> wrote in message
news:OY**************@TK2MSFTNGP09.phx.gbl... Hi there,
I am having a problem with an ASP.NET DropDown list - whenever I set the
SelectedValue (or SelectedIndex) property, when the page displays, only
the first item is ever selected. This is a databound dropdown, and I have
executed the DataBind() method prior to trying to set the selectedvalue
property. Both are being done in the Page_Load method, and only if the
page is not posting back.
Any ideas would be appreciated.
-Steven