创建分组转发器布局

时间:2014-01-30 13:52:00

标签: c# asp.net .net sql-server repeater

<asp:DropDownList ID="ddlGroupSearch" CssClass="cssTextbox" runat="server">
    <asp:ListItem Value="1" Text="Referring Physician Wise"></asp:ListItem>
    <asp:ListItem Value="2" Text="Specialty Wise"></asp:ListItem>
</asp:DropDownList>


<asp:Repeater runat="server" ID="repeaterParent" OnItemDataBound="repeaterParent_ItemDataBound">
    <ItemTemplate>
        <tr>
            <td>                            
                <asp:Label ID="lblREF_PHY_ID" runat="server" Text='<%# this.RenderGroup(Eval("REF_PHY_ID") as string)%>'></asp:Label>
            </td>
        </tr>
        <tr>
            <td class="cssTableListTd">
                <asp:Label ID="lblPatNameListData" runat="server" Text='<%#Eval("Patient_Name")%>'></asp:Label>
            </td>
            <td class="cssTableListTd">
                <asp:Label ID="lblPatIDListData" runat="server" Text='<%#Eval("Patient_ID")%>'></asp:Label>
            </td>
            <td class="cssTableListTd">
                <asp:Label ID="lblPatSexListData" runat="server" Text='<%#Eval("Sex")%>'></asp:Label>
            </td>
            <td class="cssTableListTd">
                <asp:Label ID="lblPatBirthDateListData" runat="server" Text='<%#Eval("Patients_Birth_Date")%>'></asp:Label>
            </td>
        </tr>
    </ItemTemplate>
</asp:Repeater>

c#中

protected void Page_Load(object sender, EventArgs e)
{
    //get data bind to repeater
    repeaterParent.DataSource = DataTable;
    repeaterParent.DataBind();.
}  

string lastValue = "";
protected string RenderGroup(string currentValue)
{
    if(currentValue == this.lastValue)
        return "";//Group has changed    
    this.lastValue = currentValue;
    return currentValue;
}

我必须明智地向报告小组展示。我的页面中有DropDownList。现在根据DropDownList值,我必须调用RenderGroup函数。我该怎么打电话给中继器?

我已经参考了这个链接 ref link

1 个答案:

答案 0 :(得分:0)

您是否尝试过将功能分组应用于DataTable,以便绑定到转发器?

我指的是下面的内容。

参考:Link

谢谢!