以字符串形式获取复选框的选定项 [英] Get the selected items of checkbox in a string

查看:62
本文介绍了以字符串形式获取复选框的选定项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在转发器控制中,我具有带有复选框的公司名称列表....如果我选择公司名称,将对其进行检查.....我在转发器控制中具有for循环,如果选中了这些项,则它进入chk.checked状态..否则在循环之外...如何以字符串形式获取所选公司ID ...请帮助我...尽快

In repeater control , i am having list of company names with checkbox.... if i select the company names it will be checked .....i am having for loop for repeater control ,if the items are checked then it goes into the chk.checked condition..otherwise outside the loop...how to get the selected company id in a string......Please help me...as soon as possible

protected void btnPDF_Click(object sender, EventArgs e)
      {
          //string memberno = "Repeater items checked:<br/>";
          string lblid = string.Empty;

          for (int itemcount = 0; itemcount < Rpt_Company.Items.Count; itemcount++)
          {
              CheckBox chkbox = ((CheckBox)Rpt_Company.Items[itemcount].FindControl("chkbox"));
              if (chkbox != null && chkbox.Checked == true)
              {

                 // lblid=Rpt_Company.Items[itemcount].FindControl("chkbox");
                 // lblid = chkbox.Text;
                //  memberno += chkbox.Text;
                  //memberno += (chkbox.Text + "<br/>");
                  //Literal lbl = (Literal)Rpt_Company.Items[itemcount].FindControl("chkbox");

                  //Label lbl = (Label)Rpt_Company.Items[itemcount].FindControl("chkbox");

                  // lblid = lbl.Text;


              }
          }

推荐答案


您可以在btnPDF_Click本身中分配字符串,而不是使用EVAL.
您的代码以任何方式进行回发.只是这样分配

Hi,
Instead of using EVAL you can assign the string in the btnPDF_Click itself.
Any way your code goes for a postback. Just assign like this

TempData.Text = memberno;



认为这会有所帮助.



Think this would help.


这篇关于以字符串形式获取复选框的选定项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆