Show gridview footer on empty grid?

后端 未结 6 2179

just wanted to know what is the best and easiest way to show a gridview footer for data entry even when the gridview is empty ?

6条回答
  •  不知归路
    2020-12-06 18:12

    Ideally you only want to show the dummy row if there are no records in the table yet. So set your SelectCommand to something like this:

    SELECT [ID], FirstName, LastName, Email FROM Customers union SELECT 0 [ID], '' FirstName, '' LastName, '' Email where 0 in (SELECT COUNT(1) from Customers)

    That way if the count > 0, the dummy row isn't returned.

    Note that the dummy row does not have a FROM clause in it.

提交回复
热议问题