1

中继器标记:

<asp:Repeater ID="Repeater_sorular" runat="server" OnItemCommand="Repeater_sorular_ItemCommand"
        OnItemDataBound="Repeater_sorular_ItemBound">
        <HeaderTemplate>
        </HeaderTemplate>
        <ItemTemplate>
            <table>
                <tr>
                    <td>
                        <rad:RadChart ID="RadChart1" runat="server" DefaultType="Pie" Width="700">
                            <PlotArea Appearance-FillStyle-FillType="Gradient" Appearance-FillStyle-MainColor="#D90420"
                                Appearance-FillStyle-SecondColor="#FFAD4A" Appearance-Border-Visible="false">
                                <EmptySeriesMessage>
                                    <TextBlock Text="Seçilen anket henüz oylanmamıştır.">
                                        <Appearance TextProperties-Font="Tahoma, 10pt, style=Bold">
                                        </Appearance>
                                    </TextBlock>
                                </EmptySeriesMessage>
                            </PlotArea>
                            <ChartTitle>
                                <TextBlock Appearance-TextProperties-Font="Tahoma">
                                </TextBlock>
                            </ChartTitle>
                            <Appearance ImageQuality="HighQuality" Border-Color="#DFDDDD" TextQuality="ClearTypeGridFit">
                            </Appearance>
                            <Series>
                                <rad:ChartSeries Type="Pie" Appearance-TextAppearance-TextProperties-Color="#FFFFFF"
                                    Appearance-TextAppearance-TextProperties-Font="Tahoma">
                                </rad:ChartSeries>
                            </Series>
                            <Legend Visible="True">
                                <TextBlock Visible="True">
                                </TextBlock>
                            </Legend>
                        </rad:RadChart>
                    </td>
                    <td>
                        <div style="font-weight: bolder; padding: 5px;">
                            <%#(((RepeaterItem)Container).ItemIndex+1).ToString() %>.
                            <%#Eval("Subject")%>
                        </div>
                        <asp:BulletedList ID="BulletedList_secenekler" runat="server" DataSource='<%#Eval("Secenekler")%>'
                            DataTextField="OptionName" DataValueField="OptionId" CssClass="sira_numarali">
                        </asp:BulletedList>
                    </td>
                </tr>
            </table>
        </ItemTemplate>
        <FooterTemplate>
        </FooterTemplate>
    </asp:Repeater>

和中继器ItemDataBoundEvent

protected void Repeater_sorular_ItemBound(object sender, RepeaterItemEventArgs e)
{
    RadChart RadChart1 = (RadChart)e.Item.FindControl("RadChart1");
    BulletedList bl = (BulletedList)e.Item.FindControl("BulletedList_secenekler");
}

当我调试它控制返回null。我该如何解决。

谢谢。

4

1 回答 1

6

为您拥有的每一行调用该方法,包括标题。第一行可能是空的,因为第一行是标题(它是空的)。为了解决它,您需要使用过滤方法

if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {
    //your code 
}
于 2012-06-20T06:10:21.477 回答