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

posted on 2013-11-14 11:27  御不凡  阅读(364)  评论(0编辑  收藏  举报