如何通过单击gridview外部的按钮来改变gridview的值 [英] How to chane gridview value by clicking button outside gridview
问题描述
亲爱的先生,
我正在使用gridview,并且每行都有一个复选框,有2个按钮,可以在gridview外部接受和拒绝.
如果我单击接受,则所有选中的行的字段值都应更改为接受,如果我单击拒绝,则所有选中的行的字段值都应更改为拒绝.共有3列,只有一列会更改.请帮助我解决.
谢谢和问候
N.拉马坎德兰
[edit]已删除呼喊声-OriginalGriff [/edit]
Dear Sir,
I am having gridview and i have check box for each row,there are 2 buttons ,accept and reject outside the gridview .
If i click accept all the checked rows field value should change to accept and if i click reject all the checked rows column value should change to reject.There are 3 columns only one column will change.Please help me to solve .
Thanks and regards
N.Ramachandran
[edit]SHOUTING removed - OriginalGriff[/edit]
推荐答案
这是您问题的代码
here is the code for your problem
private void button1_Click(object sender, EventArgs e)
{
foreach(DataGridViewRow Row in dataGridView1.Rows)
{
if (Row.IsNewRow)
{
}
else if (Row.Cells[2].Value == null)
{
}
else if (Row.Cells[2].Value.ToString() == bool.TrueString)
{
Row.Cells[0].Value = "Accepted";
dataGridView1.Refresh();
}
}
}
我检查了空值,因为当您不检查它时,它会给您一个错误
I checked for null value because when you leave one unchecked it will give you an error
这篇关于如何通过单击gridview外部的按钮来改变gridview的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!