在没有数据库 / SQL的GridView中搜索项目

发布于 2025-01-21 19:46:45 字数 434 浏览 1 评论 0原文

(ItemGridView.DataSource as DataTable).DefaultView.RowFilter = string.Format("OR Name like '{0}%'", searchBox.Text);

尝试通过使用以下代码从如何在C#Windows表单应用程序中的数据GridView中搜索?并获得了一个System.NullReferenceException:'对象引用未设置为对象的实例。'。有什么可以解决的吗?

C#非常新,需要帮助。

(ItemGridView.DataSource as DataTable).DefaultView.RowFilter = string.Format("OR Name like '{0}%'", searchBox.Text);

Trying search an item in my GridView by using the following line of code from How to search in Data gridview in C# Windows Form application? and got a System.NullReferenceException: 'Object reference not set to an instance of an object.'. Is there anything to solve this?

Very new to c# and need help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文