Select method of ObjectDataSource called twice

T

TarTar

Hello,

I have the following code on my ASP.NET page:

<asp:DataList ID="CustomersList" DataSourceID="CustomerDataSource"
runat="server">
<ItemTemplate>
Name: <asp:Label id="lblName" Text='<%# Eval("Name") %>'
runat="server"/>
</ItemTemplate>
</asp:DataList>
<asp:ObjectDataSource ID="CustomerDataSource" SelectMethod="GetCustomers"
TypeName="Customers" runat="server" />

and code-behind:

public class Customers
{
public List<Customer> GetCustomers()
{
Customer test = new Customer();
test.Name = "Uakari Mabuto";
List<Customer> list = new List<Customer>();
list.Add(test);
return list;
}
}
public class Customer {...}

Why the GetCustomers() method is called twice when the page launches. Then
on subsequent postbacks, it is called only once. I would like the method to
be called once in all cases.

Thanks,
Leszek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top