选择gridview中的复选框,它表示您已选择重复值 [英] Selecting checkbox in gridview and it show that u have selected the duplicate value
本文介绍了选择gridview中的复选框,它表示您已选择重复值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个gridview,其中我添加了复选框,按钮单击我已显示警告消息你已选择相同的值两次。我无法执行此任务我使用循环但无法使用复选框匹配值。
忽略括号
i have a gridview in which i add the check box, on button click i have show the alert message that "u have selected the same value twice" . i am unable to this task i have use loop but cant able to match the value using check box.
ignore the bracket
for (int i = 0; i < rowcount - 1; i++)
{
string Breaktype1= popgvdetails.Rows[j].Cells[6].Text;
CheckBox checklist = (CheckBox)popgvdetails.Rows[i].FindControl("popcheck");
if (checklist.Checked == true)
{
for (int j = 0; j < rowcount - 1; j++)
{
if (i != j)
{
string Breaktype2 = popgvdetails.Rows[j].Cells[6].Text;
if (Breaktype1 == Breaktype2)
{
ClientScript.RegisterStartupScript(this.GetType(), "disExp", "<script> alert('You have select the same Break Type');</script>");
}
j++;
}<pre lang="c#">
}
}
推荐答案
现在,我给出一些代码,如下所示:
Now,I give some code ,as follows :
protected void Button1_Click(object sender, EventArgs e)
{
int count = 0;
string items = "";
foreach (GridViewRow item in GridView1.Rows)
{
CheckBox cb = (CheckBox)item.FindControl("CheckBox2");
if (cb.Checked)
{
items = items + item.Cells[1].Text;//
count++;
}
}
Response.Write(count.ToString() + items);
}
这篇关于选择gridview中的复选框,它表示您已选择重复值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文