Gridview disappears if there is no result RRS feed

  • Question

  • User1332450904 posted

    I have a Gridview that has as datasource the standard SqlDataSource1. A user can change the query based on a dropdown and this works fine. But when there is no result the whole gridview disappears. This is the code that gets activated when the dropdown is changed, it's fairly simple but to just give an example on what I am doing:

    SqlDataSource1.SelectCommand = "SELECT * from Kist where Rij ='" + DropDownList1.Text + "'";

    If there are no results with the 'Rij' column the Gridview disappears. I want it to stay, so the user does not have to refresh the page to be able to use it again.

    By the way, yes I know my query is easy recipe for a SQL Injection. The project is only for private use.

    Friday, May 29, 2020 10:37 AM


  • User1332450904 posted

    I already discovered the problem myself. Because there is no page reload the Gridview can't come back. So I just removed the Updatepanel and everything works fine now.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 30, 2020 10:00 AM