zoukankan      html  css  js  c++  java
  • repeater嵌套RadioButtonList赋值

        <asp:Repeater ID="Repeater1" runat="server"
            onitemdatabound="Repeater1_ItemDataBound">
            <ItemTemplate>
                <%# Convert.ToDateTime(Eval("createtime")).ToShortDateString() %><br />
                <a href='<%#Eval("id") %>'></a><%--传参用--%>
                <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal">
                    <asp:ListItem Value="aa">aa&nbsp;&nbsp;</asp:ListItem>
                    <asp:ListItem Value="bb">bb&nbsp;&nbsp;</asp:ListItem>
                    <asp:ListItem Value="cc">cc&nbsp;&nbsp;</asp:ListItem>    
                </asp:RadioButtonList>
                备注<asp:TextBox ID="txtDetail" Width="500px" Height="50px" runat="server"></asp:TextBox><br /><br />
            </ItemTemplate>
        </asp:Repeater>

    cs代码页:

        protected void BindRepeater1()
        {
            kaoqinTab = kaoqinAda.GetData(**);
            Repeater1.DataSource = kaoqinTab;
            Repeater1.DataBind();
        }

        //绑定原考勤信息
        protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                RadioButtonList rbl = e.Item.FindControl("RadioButtonList1") as RadioButtonList;
                TextBox txtDetail = e.Item.FindControl("txtDetail") as TextBox;
                DataRowView rowv = (DataRowView)e.Item.DataItem;
                string id = rowv["id"].ToString();
                kaoqinTab = kaoqinAda.GetDataById(Convert.ToInt32(id));
                if ("1" == kaoqinTab[0]["aaaa"].ToString())
                {
                    rbl.SelectedValue = "aa";
                }
                if ("1" == kaoqinTab[0]["bbbb"].ToString())
                {
                    rbl.SelectedValue = "bb";
                    txtDetail.Text = kaoqinTab[0]["bbDetail"].ToString();
                }
                if ("1" == kaoqinTab[0]["cccc"].ToString())
                {
                    rbl.SelectedValue = "cc";
                    txtDetail.Text = kaoqinTab[0]["ccDetail"].ToString();
                }
            }
        }

  • 相关阅读:
    jQuery 往table添加新内容有以下四个方法:
    Postgresql 截取字符串
    如何取得select结果数据集的前10条记录。postgresql
    postgreSQL除法保留小数
    Java面试——微服务
    Vue面试中,经常会被问到的面试题/Vue知识点整理
    Java面试之五大框架的理解
    Session共享的四种方法
    ES6参考---三点运算符实质
    VUE实例课程---40、counter实例
  • 原文地址:https://www.cnblogs.com/yubufan/p/3422950.html
Copyright © 2011-2022 走看看