开发者

Force the user to select minimum two check boxes in each section in gtrid view?

开发者 https://www.devze.com 2023-01-09 08:21 出处:网络
I have to select checkboxes besed on group column values. If you see below gridview, column 3 (GroupNo) has 1,1,1,1,2,2,2,2....etc (this column data is not static, will change based on page index. i.e

I have to select checkboxes besed on group column values. If you see below gridview, column 3 (GroupNo) has 1,1,1,1,2,2,2,2....etc (this column data is not static, will change based on page index. i.e PageIndex =2 may starts with 7,7,7,8,8,8,8,8,9,9,9 etc).

Now My question is.

In every sectio/Group User must and should select minimun 2 check boxes. so If user select only one check box we need to show a pop up message as " Please select One more check box in that particular section" If User skips the message and move to next section we have to show the same message. We have to force the user to select more than one checkbox in the same section.

Mainly our intention is the check boxes whatever user selected in each section/Group belongs to one Category.

Please help me in this requirement. Thanks in 开发者_运维问答advance.

Force the user to select minimum two check boxes in each section in gtrid view?


you need to use custom Validator and need to check this in code behind to iterate gridview rows Edit: Something like you need to add more checks.....

int GroupCount = 0;
 for (int count = 0; count < grd.Rows.Count; count++)
{
    int GroupNo = ((label)grd.Rows[count].FindControl("yourGroupNoLable")).Text;
    if (((CheckBox)grd.Rows[count].FindControl("yourCheckbox")).Checked)
    {
        GroupCount = GroupCount + 1;
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消