【发布时间】:2011-04-14 21:08:36
【问题描述】:
我正在向 gridview 动态添加一列...它是一列复选框 - 用户检查它们以确定他们要打印的行。我希望能够在不使用数字索引的情况下获得对单元格的引用:
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[4].Controls.Count == 0)
{
CheckBox cbPrint = new CheckBox();
cbPrint.ID = "chkPrint";
cbPrint.Checked = false;
e.Row.Cells[4].Controls.Add(cbPrint); <--- this line
}
}
我希望能够像在 e.Row.Cells["Print"] 中使用“打印”,就像在 DataSet 中使用列一样 - 例如:ds.Tables[0].Rows[3][" Print"],其中 print 指定列。我希望能够做到这一点,因为打印列在每个 GridView 中可能不在同一个位置,并且使用数字索引可能不会一直有效。有没有办法使用字符串列引用来获取单元格??
【问题讨论】:
标签: gridview