A
anastasia
I have the following code (this is a snippet):
InitDBConn();
OpenDBConnection();
OleDbCommand cmdRidge = new OleDbCommand("SELECT * FROM
TRDRidgeTypes", oleDbConn);
OleDbDataReader oleRidges= cmdRidge.ExecuteReader();
if (!this.IsPostBack)
{
ddlRidge.DataSource = oleRidges;
ddlRidge.DataMember = "TRDRidgeTypes";
ddlRidge.DataTextField = "RidgeType";
ddlRidge.DataValueField = "RidgeTypeID";
ddlRidge.DataBind();
}
----
This code successfully fills a DropDownList box. However, when the
user selects one of the items and the page is posted to the server
,the SelectedItem property of the List is null and the SelectedIndex i
(-1). I am tearing my hair out because I have found people on the
newsgroup with a similar
problem, but it was due to their not setting data source in the
"this.PostBack =False" condition. I have done that, and it still does
not help me.
I do have ViewState for the control set to True. I tried hardcoding
the ListItems in the HTML and the control values were read correctly.
I am sure I am missing the obvious here..but please help!!
Thanks,
Stacey
InitDBConn();
OpenDBConnection();
OleDbCommand cmdRidge = new OleDbCommand("SELECT * FROM
TRDRidgeTypes", oleDbConn);
OleDbDataReader oleRidges= cmdRidge.ExecuteReader();
if (!this.IsPostBack)
{
ddlRidge.DataSource = oleRidges;
ddlRidge.DataMember = "TRDRidgeTypes";
ddlRidge.DataTextField = "RidgeType";
ddlRidge.DataValueField = "RidgeTypeID";
ddlRidge.DataBind();
}
----
This code successfully fills a DropDownList box. However, when the
user selects one of the items and the page is posted to the server
,the SelectedItem property of the List is null and the SelectedIndex i
(-1). I am tearing my hair out because I have found people on the
newsgroup with a similar
problem, but it was due to their not setting data source in the
"this.PostBack =False" condition. I have done that, and it still does
not help me.
I do have ViewState for the control set to True. I tried hardcoding
the ListItems in the HTML and the control values were read correctly.
I am sure I am missing the obvious here..but please help!!
Thanks,
Stacey