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();
                }
            }
        }

  • 相关阅读:
    二维线性表 list实现
    行测题
    邻接表
    链表中插入和删除结点
    linux监控指标和命令
    lr测试结果分析
    python 装饰器 decorator
    并查集 PID331 / 家族
    素数环 dfs+回溯
    catch the cow bfs
  • 原文地址:https://www.cnblogs.com/yubufan/p/3422950.html
Copyright © 2011-2022 走看看