如何使 gridview 仅在输入信息后才填充?
我确信这非常简单,但我有一个 gridview、tableadapter、objectdatasource 和一个文本框。
当我运行该页面时,我得到:
值不能为空。 参数名称:permanent
这是因为我的查询有一个从文本框中查找的参数。如果我手动输入文本框文本值的数据并加载页面,则查询运行正常。
如何才能使查询仅在将数据放入文本框后运行?我不希望在有人输入内容进行搜索之前运行查询。我查看了所有属性并没有看到任何明显的东西。
谢谢。
I am sure this is incredibly simple but I have a gridview, tableadapter, objectdatasource, and a textbox.
When I run the page I get:
Value cannot be null.
Parameter name: permanent
This is because my query has a parameter that it is looking for from the textbox. If I manually enter in data for the textbox's text value and load the page, the query runs fine.
How do I make it so the query only runs after I put data into my textbox? I don't want the query to run until someone put something in to search for. I looked at all the properties and didn't see anything obvious.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在不知道有关您的设置的任何重要细节的情况下,我会说您需要使用某种事件和 if 语句。我将创建一个按钮来检查文本框中是否存在某些内容,然后处理查询。我假设您正在使用 ASP.NET。您可以使用 TextBox.Text.Length 检查 TextBox 中文本的长度。
像这样的事情:
当然,如果您的特定用途需要它,您始终可以将其放入文本更改事件中,以便它对输入的每个新字符进行查询。
Without knowing any significant details about your setup, I would say you need to use some sort of event and an if statement. I would create a button which checks that something exists in the textbox and then processes the query. I am assuming you are using ASP.NET. You can use TextBox.Text.Length to check the length of the text in the TextBox.
Something like this:
Of course, if your particular use calls for it, you can always put it in a text changed event so it does a query for each new character entered.