Below is a basic example to explain what my concern is. I have a listview that gets data from SQL Server and has OnItemDataBound event which loops through each row of the data. And in C#, the event function ListView1_ItemDataBound is called for each row because when I place a breakpoint in the event function ListView1_ItemDataBound, it breaks once per row. Since the code written in C# is executed in the server(not sure if I'm correct on this), does it mean the user needs to connect to my server 10 separate times(10 connection requests) if there are 10 rows that listview retrieved from the database? If yes, doesn't this affect the server's performance? Is it good to avoid using OnItemDataBound ?
aspx
<asp:Listview ID="ListviewContent" runat="server" DataKeyNames="UniqueNo" DataSourceID="SqlDataSource1" OnItemDataBound="ListView1_ItemDataBound">
<ItemTemplate>
<asp:Button id="btn_popup" text="Popup" runat="server" Visible="false" /> ..................
C#
protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e){...Find the button control and on certain condition make it visible or whatever you need...}