How to get a gridview to show all table rows when no text is entered in a dependent textbox?

前端 未结 2 502
臣服心动
臣服心动 2021-01-16 11:40

The below works correctly and filters my gridview based on the text entered in my textbox.

When no text is entered into my textbox I get no results and cannot unders

2条回答
  •  误落风尘
    2021-01-16 12:24

    Look at CancelSelectOnNullParameter - by default, this prevents the select command from being called when a select parameter's value is null. After setting it to false, the select SP will then still get called even if the text box is empty, e.g.

    
    
    

    The SqlDataSource seems a bit misleading to me here, because TextBox.Text returns String.Empty when it's empty, not null, therefore I wouldn't expect to have to mess with CancelSelectOnNullParameter for a TextBox, but it seems we have to.

提交回复
热议问题