如果第三列也是控件的话 int num = gridview.Rows.Count; for (int i = 0; i < num;i++ ) { Label labplan1 = gridview.Rows[i].FindControl("labplan1") as Label; } 这样就可以取到你前台第三列控件了,然后就可以取出值来赋给textbox了,此处的labplan1是前台控件的id号
List<string> list = new List<string>(); foreach(DataGridViewRow r in this.dgv.Rows) { if(r.Cells[0].Value == null) { continue; } if((bool)r.Cells[0].Value) { list.Add(this.dgv.CurrentRow.Cells[2].Value.ToString()); } }
List<string> list = new List<string>(); foreach(DataGridViewRow r in this.dgv.Rows) { if(r.Cells[0].Value == null) { continue; } if((bool)r.Cells[0].Value) { list.Add(r.Cells[2].Value.ToString()); //搞错啦 } }
int num = gridview.Rows.Count;
for (int i = 0; i < num;i++ )
{
Label labplan1 = gridview.Rows[i].FindControl("labplan1") as Label;
}
这样就可以取到你前台第三列控件了,然后就可以取出值来赋给textbox了,此处的labplan1是前台控件的id号
foreach(DataGridViewRow r in this.dgv.Rows)
{
if(r.Cells[0].Value == null)
{
continue;
}
if((bool)r.Cells[0].Value)
{
list.Add(this.dgv.CurrentRow.Cells[2].Value.ToString());
}
}
foreach(DataGridViewRow r in this.dgv.Rows)
{
if(r.Cells[0].Value == null)
{
continue;
}
if((bool)r.Cells[0].Value)
{
list.Add(r.Cells[2].Value.ToString()); //搞错啦
}
}