如何将网格的值放入单列 [英] How to get the values of a grid into single column
问题描述
在我的应用程序中,我正在使用gridview.我在该网格中有三个字段,例如:
复选框documentNumber字段
PTo1 1
PTo2 2
PTo3 3
在这里,我将选中此复选框,然后单击保存"按钮.我需要将文档号保存到数据库中,并用逗号和单引号将所有值连接在一起,例如"Pto1","PTo2" ',''Pto3''.
谁能帮我解决这个问题
在此先感谢您
Hi,
In my application I am using the gridview. I am have three fields in that grid like:
Checkbox documentNumber field
PTo1 1
PTo2 2
PTo3 3
Here I will check this checkbox and click the save button what I need is I want to save the document number into the database with concatenating all the values with comma and single quotes in a single column like ''Pto1'',''PTo2'',''Pto3''.
Can any one help me to solve this issue
Thanks in advance
推荐答案
我假设您正在应用程序中使用CheckboxList选择多个值,然后单击保存按钮.
试试:
I assume you are using CheckboxList in your application to select multiple values and then hit save button.
Try:
for (int i = 0; i < clist.Items.Count; i++)
{
if (clist.GetItemCheckState(i) == CheckState.Checked)
// Do selected stuff
// concatenate the document number here of the current item
// likeString += "'" + currentDocNo + "'";
else
// Do unselected stuff
}
这篇关于如何将网格的值放入单列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!