views:

99

answers:

1

Hi Everybody , i want to call a function to bind data to Repeater . Do I need to Set dataSource Property of this control or Repeater .DataBind() will work.

 <asp:Repeater ID="RepeaterDays" runat="server">
     <ItemTemplate>
            <ul>
                <asp:Label ID="lblDays" runat="server" Text='<%#ChandanIdiot()%>'></asp:Label>
             </ul>
       </ItemTemplate>
   </asp:Repeater>

and I have written RepeaterDays.Databind() but function is not being called.

this is displaying nothing.

Please Help

A: 

Is ChandanIdiot() a protected function that returns a string?

    protected string ChandanIdiot() {
        return "test";
    }

If you want to actually do some data processing, you will have to include a parameter:

    protected string ChandanIdiot(object obj) {
        return "test " + obj;
    }

And, assuming that there is a property called "Name" on the object that you are reapeating, you would have the following:

<asp:Label ID="lblDays" runat="server" Text='<%# ChandanIdiot(Eval("Name")) %>' />
Daniel Dyson