日期:2014-05-18  浏览次数:20588 次

repeater 的HeaderTemplate里面的label应该如何动态赋值?
C# code

                <HeaderTemplate>
                <table class="tablesorter" style="word-break:break-all;table-layout:fixed; font-size:20px;">
                    <thead>
                        <tr>
                            <th style="width:60px;"><asp:Label ID="Label1" runat="server"></asp:Label></th>
                            <th style="width:60px;"><asp:Label ID="Label2" runat="server"></asp:Label></th>
                            <th style="width:60px;"><asp:Label ID="Label3" runat="server"></asp:Label></th>
                            <th style="width:60px;"><asp:Label ID="Label4" runat="server"></asp:Label></th>
                            <th style="width:60px;"><asp:Label ID="Label5" runat="server"></asp:Label></th>
                            <th style="width:60px;"><asp:Label ID="Label6" runat="server"></asp:Label></th>
                            <th style="width:60px;"><asp:Label ID="Label7" runat="server"></asp:Label></th>                                          
                        </tr>
                   </thead>
                   <tbody>
                </HeaderTemplate>



------解决方案--------------------
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Header)
{
Label Label1 = e.Item.FindControl("Label1") as Label;
Label1.Text = "xxx";
}
}