T
TarTar
Hello,
I have already posted this problem, but I have not received any response
yet. I will try to describe it again.
We have a list control (e.g. DataList) and an ObjectDataSource on an ASP.NET
web page. When we open the page the Select method (here: GetCustomers) is
called twice. Why? It is obvious performance hit as the data needs to be
retrieved twice. How to avoid the duplicated calls?
Below there is complete code for both the ASP.NET page and its code-behind:
<asp
ataList ID="CustomersList" DataSourceID="CustomerDataSource"
runat="server">
<ItemTemplate>
Name: <asp:Label id="lblName" Text='<%# Eval("Name") %>'
runat="server"/>
</ItemTemplate>
</asp
ataList>
<asp:ObjectDataSource ID="CustomerDataSource" SelectMethod="GetCustomers"
TypeName="Customers" runat="server" />
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
{
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
}
Thanks,
Leszek
I have already posted this problem, but I have not received any response
yet. I will try to describe it again.
We have a list control (e.g. DataList) and an ObjectDataSource on an ASP.NET
web page. When we open the page the Select method (here: GetCustomers) is
called twice. Why? It is obvious performance hit as the data needs to be
retrieved twice. How to avoid the duplicated calls?
Below there is complete code for both the ASP.NET page and its code-behind:
<asp
![Big Grin :D :D](/styles/default/custom/smilies/grin.gif)
runat="server">
<ItemTemplate>
Name: <asp:Label id="lblName" Text='<%# Eval("Name") %>'
runat="server"/>
</ItemTemplate>
</asp
![Big Grin :D :D](/styles/default/custom/smilies/grin.gif)
<asp:ObjectDataSource ID="CustomerDataSource" SelectMethod="GetCustomers"
TypeName="Customers" runat="server" />
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
{
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
}
Thanks,
Leszek