I have the following set up, a ddl (ddlProd, radBuyer) and autocomplete text box (txtProdAC, radProd) that when populated and their respective radio buttons are selected, a grid view of the data is produced...lovely stuff.
protected void btSearch_Click(object sender, EventArgs e)
{
lqPackWeights.WhereParameters.Clear();
ControlParameter cp = new ControlParameter();
cp.Type = TypeCode.String;
if (radBuyer.Checked)
{
cp.ControlID = "ddlProd";
cp.PropertyName = "SelectedValue";
}
if (radProd.Checked)
{
cp.ControlID = "tbxProdAC";
cp.PropertyName = "Text";
}
else
{
cp.ControlID = "lbRadMiss";
cp.PropertyName = "Text";
lbRadMiss.Text = "Please check appropriate radio button before you attempt a search";
}
cp.Name = "IDDesc";
lqPackWeights.WhereParameters.Add(cp);
GridView1.DataSourceID = "lqPackWeights";
GridView1.DataBind();
}
I stuck in the else
section so that should a user hit the Search button without a radio button being checked, a label would appear and saying "Please check...etc"
This works fine but I have a slight problem. If a user produces this validation (the else), he or she would then naturally hit the appropriate radio button and then click search again. However, when this process is followed, my code seems to ignore it's job and does not pick up either the selected value for the ddl or the text from the tbxProdAC. The else label remains and the grid view remains empty.
Can someone point me in the direction with this.