关于checkbox选值在前台设置隐藏域的方法

若是在gridview中进行选择+上checkbox列的话,当你勾选checkbox的一列并将这一列gridview中的值传到下一个界面,则应该将这个

hidden区域放在girdview中选择值放在跳转按钮的属性下面,然后进行

foreach (GridViewRow row in this.gridView.Rows)
        {
            TableCell cell = row.Cells[0];
            var chk = (CheckBox)row.FindControl("CheckBoxItem");
            if (chk.Checked)
            {
                var selectindex = (chk.NamingContainer as GridViewRow).RowIndex;
                var Companycode = this.ddlCompanyCode.SelectedValue;
                var Pricecode = ((HiddenField)gridView.Rows[selectindex].FindControl("hiddenfieldPricecode")).Value;
                string url = "PriceForm4Modify.aspx?Pricecode=" + Pricecode + "&Companycode=" + Companycode + "";
                Response.Redirect(url);
            }
        }

若是直接点击跳转按钮未经勾选默认选择本行则将hidden区域放在checkbox的属性中,然后进行

ImageButton imageButton = (ImageButton)sender;
        var Pricecode=Convert.ToString( imageButton.Attributes["hiddenfieldPricecode"]);
        var Companycode=Convert.ToString( imageButton.Attributes["hiddenfieldCompanycode"]);
        Response.Redirect("PriceForm4Modify?Pricecode=" + Pricecode + "&Companycode=" + Companycode + "&status="+status+"");

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值