Select a price from a ddl to populate a gridview with the items that cost the selected price or less. response.write is null at start and if there is only one item in the gridview. Else, response.write should display the amount of items and the selected price.
The issue is that when a price is selected, response.write posts the correct selected price from the ddl, but the amount of rows from the gridview corresponds to the amount seen in the prior screen. If the data from the gridview is edited or sorted, it will effectively show the correct amount of rows (the ddl has not been altered, so it shows the amount from the previous screen, which equals the amount of the current screen.)
here is the code for default.aspx.cs:
public partial class _Default : System.Web.UI.Page
{
string numberOfItems;
string selectedPrice;
protected void Page_Load(object sender, EventArgs e)
{
numberOfItems = Convert.ToString(GridView1.Rows.Count);
selectedPrice = ddlPrice.SelectedValue.ToString();
if (!IsPostBack)
{
Response.Write("<br />");
}
else
{
if (Convert.ToInt32(numberOfItems) <= 1)
{
Response.Write("<br />");
}
if (Convert.ToInt32(numberOfItems) > 1)
{
Response.Write("There are " + numberOfItems +
" products that cost $" + selectedPrice + " or less.");
}
}
}
protected void ddlPrice_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
Thank you