M
musosdev
Hi
I'm trying to set the selected item on a dropdownlist on my c# asp.net page.
Here's the code...
private void Page_Load(object sender, EventArgs e)
{
setuplist();
ddlPrimaryAOW.SelectedValue = sqlDR["PrimaryAOW"].ToString();
}
The SelectedValue statement fails with an indexoutofrange exception.
My setuplist() function adds items to the list, like so...
ddlPrimaryAOW.Items.Add(new listitem("item1", "i1"));
so I would expect if sqlDR["PrimaryAOW"].ToString() = "i1", then the code
should work?! I know that the list is populating correctly, and that one of
my items has the value "i1", and I know the result of
sqlDR["PrimaryAOW"].ToString() also = "i1".
What am I doing wrong?!
Thx, dan.
I'm trying to set the selected item on a dropdownlist on my c# asp.net page.
Here's the code...
private void Page_Load(object sender, EventArgs e)
{
setuplist();
ddlPrimaryAOW.SelectedValue = sqlDR["PrimaryAOW"].ToString();
}
The SelectedValue statement fails with an indexoutofrange exception.
My setuplist() function adds items to the list, like so...
ddlPrimaryAOW.Items.Add(new listitem("item1", "i1"));
so I would expect if sqlDR["PrimaryAOW"].ToString() = "i1", then the code
should work?! I know that the list is populating correctly, and that one of
my items has the value "i1", and I know the result of
sqlDR["PrimaryAOW"].ToString() also = "i1".
What am I doing wrong?!
Thx, dan.