【发布时间】:2014-01-04 19:57:18
【问题描述】:
我有一个gridview,它从数据库中提取了一列“产品”。
这样,我需要一个checkbox 供用户在完成后对gridview 中的每个产品进行“检查”。
我研究了 CheckBox Field VS (Template Field + CheckBox) 并决定使用 (Template Field + CheckBox) 为gridview 保存@987654325 @。
GridView 列[0] = 产品名称 GridView 列 [1] = 复选框
在“检查”了一些checkboxes之后,用户点击提交会触发下面的事件。
string checkedBy;
foreach (GridViewRow row in grvCheckList.Rows)
{
// Im not sure how to check if each checkbox has been "checked"
// or not as it is in the gridview cell.
// what I like to have is
if((checkbox in column[1]).checked == true)
{
checkedBy = // Staff name
// my codes to store the staff name into database with respective to the product listed in the gridview row
}
else
{
checkedBy = "NULL"
// my code to store "NULL" into database with respect to the product listed in the gridview row
}
}
对于平时的checkbox,我平时做的如下
if(checkbox1.checked == true )
else if(checkbox2.checked == true )
else if(checkbox3.checked == true )
etc
所以我的问题是,尽管gridview 中的每一行都使用相同的checkbox,但我如何检查每一行中的checkbox 是否已被“检查”。
【问题讨论】:
标签: c# asp.net gridview checkbox