简体   繁体   English

使用输入列表后的C#填充数据网格视图

[英]C# Fill Data Grid View after using input list

I really need your expert help :). 我真的需要您的专家帮助:)。 Expanding on what I have learnt from querying data sets using adapters and filling a Grid View. 扩展我从使用适配器查询数据集和填充网格视图中学到的知识。 I need some help on the following task. 我需要以下任务的帮助。

I have a SQL Server Database which I am querying using C#. 我有一个使用C#查询的SQL Server数据库。 I already have solid working solutions of by a date range, a specific value. 我已经有了按日期范围和特定值确定的可靠解决方案。 However, the business user would like to search by a list of values they provide as input into a form. 但是,业务用户希望通过搜索他们提供的值列表来输入表单。

Similar to the below: adapter.SelectCommand.Parameters.AddWithValue("@mindate", textBox1.Text); 类似于以下内容:adapter.SelectCommand.Parameters.AddWithValue(“ @ mindate”,textBox1.Text);

The input will be taken from a text box or similar form based element. 输入将从文本框或类似的基于表单的元素中获取。 There should be no defined limit to the number of values eg I don't want to prevent the user from inputting 100 values for example. 值的数量应该没有定义的限制,例如,我不想阻止用户输入100个值。

By way of example. 举例来说。 User input: doc1.num1.value;doc2.num1.value;doc3.num1.value etc Note: The document number field may contain a full stop. 用户输入:doc1.num1.value; doc2.num1.value; doc3.num1.value等注意:文档编号字段可能包含句号。 However, each value will be terminated by a ';' 但是,每个值都将以';'结尾。

In the above example, we would run the following query: select employee_id, docNumbers from tableName where docNumbers in (inputlist) 在上面的示例中,我们将运行以下查询:从tableName中选择employee_id,docNumber,其中docNumbers在(输入列表)中

And the output would be: Record 1: 1, doc1.num1.value Record 2: 2, doc2.num1.value Record 3: 3, doc3.num1.value 输出为:记录1:1,doc1.num1.value记录2:2,doc2.num1.value记录3:3,doc3.num1.value

Thanks in advance guys and gals. 在此先感谢大家。

我猜您正在寻找查询时正在使用IN子句。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM