代码

解决方案 »

  1.   

    单选,使用rediobuton就可以啊。为何使用checkbox
      

  2.   

    是,我一开始也用了  <asp:RadioButton ID="RBtnxz" runat="server" GroupName="1" />
    但是页面不可以单选
      

  3.   


    是,我一开始也用了 <asp:RadioButton ID="RBtnxz" runat="server" GroupName="1" />
    但是页面不可以单选 我在repeater外面就可以,里面就不行
      

  4.   

     <input id="Repeater2_ctl00_RBtnxz" type="radio" name="Repeater2$ctl00$1" value="RBtnxz" />页面源
      

  5.   

     for (int i = 0; i < this.Play_ListRepeater.Items.Count; i++)  //遍历
                {
                    CheckBox check = (CheckBox)this.Play_ListRepeater.Items[i].FindControl("Music_Box");  
                    //Label Music_lable = (Label)this.Play_ListRepeater.Items[i].FindControl("Music_Name");
                    //if (check.Checked == true)
                    //{
                    //    string aa = check.Value;
                    //    string bb = check.Name;
                    //}
                    if(check.Checked==false)
                    {
                        string aa = check.Text;
                        string bb = check.Text;
                    }
                    else
                    {
                        string aa = check.Text;
                        string bb = check.Text;
                    }
      

  6.   

    单选,使用rediobuton,并用PANEL 容器框选所有rediobuton,系统自动为你单选
      

  7.   


    panel怎么能容器框选所有rediobuton,repeater里面循环出来的
      

  8.   

    上百度找下 单选的复选框js就行了   你加到页面上应该就ok了  
      

  9.   


    //前台
     <asp:Repeater ID="Repeater1" runat="server">
         <ItemTemplate>
          <input type="checkbox" name="<%# DataBinder.Eval(Container.DataItem,"name") %>" />
          <%# DataBinder.Eval(Container.DataItem,"value") %>
         </ItemTemplate>
        </asp:Repeater>//后台
     
            DataSet ds = new DataSet();
            DataTable tbl = ds.Tables.Add("mytable");
            tbl.Columns.Add("name");
            tbl.Columns.Add("value");        // 添加新行
            DataRow row = tbl.NewRow();
            row["name"] = "test";
            row["value"] = "checkbox1";
            tbl.Rows.Add(row);        row = tbl.NewRow();
            row["name"] = "test";
            row["value"] = "checkbox2";
            tbl.Rows.Add(row);
            Repeater1.DataSource = tbl.DefaultView; 
            Repeater1.DataBind();是不是需要这样?
    我觉得像你这样还是先去找本书看比较好,
      

  10.   

    Repeater 里面设置一个TD 根据问题类型来决定使用CheckBox还是rediobuton
     <asp:Repeater ID="rptList" runat="server">
        <ItemTemplate>
            <div  style="width: 90%; margin-bottom: 5px;">
                <table class="table" width="100%" border="0">
                    <tr>
                        <td>
                            <div class="qNumber">
                                Q.<%# Container.ItemIndex + 1%></div>
                            <b>
                                <%# Eval("Title")%>
                            </b>
                        </td>
                    </tr>
                    <tr>
                        <td runat="server" id="tdOption" style="padding: 5 0 5 20;">
                        </td>
                    </tr>
                </table>
            </div>
        </ItemTemplate>
    </asp:Repeater>
      if (myDT != null) //数据不为空
            {
                rptList.DataSource = myDT;
                rptList.DataBind();
                if (myDT.Rows.Count > 0)
                {
                    for (int i = 0; i < myDT.Rows.Count; i++)
                    {
                        bool IsType = myDT.Rows[i]["Type"].ToString() == "1" ? true : false; //0 单选 1 多选
                        if (IsType)//多选
                        {                        CheckBoxList ckblist = new CheckBoxList();
                            ckblist.ID = "ckbAnswer" + i;
                            DataTable optionDT = new DataTable();
                            optionDT //问题的数据                        if (optionDT != null)
                            {
                                ckblist.DataSource = optionDT;
                                ckblist.DataTextField = "答案";
                                ckblist.DataValueField = "答案值";
                                ckblist.DataBind();
                            }                        HtmlTableCell tdOption = (HtmlTableCell)rptList.Items[i].FindControl("tdOption");
                            tdOption.Controls.Add(ckblist); //添加到TD里面去
                        }
                        else
                        {                        RadioButtonList rbtlist = new RadioButtonList();
                            rbtlist.ID = "rbtlist" + i;
                            DataTable optionDT = new DataTable();
                            optionDT //问题的数据 自己去拿吧
                            if (optionDT != null)
                            {
                                rbtlist.DataSource = optionDT;
                                rbtlist.DataTextField = "答案";
                                rbtlist.DataValueField = "值";
                                rbtlist.DataBind();
                            }
                            HtmlTableCell tdOption = (HtmlTableCell)rptList.Items[i].FindControl("tdOption");
                            tdOption.Controls.Add(rbtlist);
                        }
                    }
    }
    }
    }
      

  11.   

    1.
    <input type="radio" name="day" id="r4" value="后天"/><label for="r4">后天</label>
    2.
    <asp:RadioButton ID="RadioButton1" runat="server" Text="今天" GroupName="day"/>
    第一可以实现单选,但是第二个不可以,问下我怎么在后台得到前台他选和这一行ID,
      

  12.   

    checkbox 单选,checkbox是repeater循环出来的,多少个不知道 js代码也可以只求单选
      

  13.   

    牛腩新闻发布系统里面有个repeater控件中根据是否登录来显示删除按钮(linkbutton),看看,也许能有启发。<asp:Repeater ID="repComment" runat="server" OnItemDataBound="repComment_ItemDataBound">  
    <ItemTemplate> 
    ......
    <asp:LinkButton ID="lbtnDelComment" onclick="lbtnDelComment_Click" CommandArgument='<%# Eval("id") %>' runat="server" Visible="false">删除</asp:LinkButton>
    <ItemTemplate> 
    </asp:Repeater>cs文件:
        // 根据session的值显示或者隐藏删除评论的按钮
        protected void repComment_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                // 判断session的值显示或者隐藏删除评论的按钮
                if (Session["admin"] != null && Session["admin"].ToString() == "niunan")
                {
                    ((LinkButton)e.Item.FindControl("lbtnDelComment")).Visible = true;
                }
            }
        }
      

  14.   

    <input type="radio" name="day" id="r4" value="后天" runat=server /><label for="r4">后天</label>后台就可以得到;