I have a drop down list on my my aspx page. This box is populated from my sqlserver db. I want to allow people to search based on the value they select from the drop down list. The problem I am encountering is that it always returns the value of the first item in my list box. I am guessing my problem spurs from my lack of knowledge of postback, please help me.
This is the code im trying to use to retrieve the value of the ddl and use it as a parameter for another method.
protected void btnTypeSearch_Click(object sender, EventArgs e)
{
photoPanel.Controls.Clear();
string type = ddType.SelectedItem.Text;
DataLayer typeLayer = new DataLayer();
DataTable dt = typeLayer.fillTbl("SELECT * FROM Trees WHERE Type='" + type + "'");
fillGallery(dt);
}
In reality I simply need a way to store the value of the currently selected item in a variable for future use.