Web
If you have a GridView, DataGrid, DetailsView, FormView, DataList or Repeater bound using DataSourceID you should never touch the controls collection in Page_Init or Page_PreInit. If you do this your declarative data-binding will be lost on any outside of the control post-back. How to check this?Example:aspx<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:Button ID="Button1" Text="Button1" runat="server" /> <asp:GridView ID="GridView1" AllowPaging="true" DataSourceID="AccessDataSource1" runat="server"> </asp:GridView> <asp:DetailsView ID="DetailsView1" DataSourceID="AccessDataSource1" AllowPaging="true" runat="server"> </asp:DetailsView> <asp:FormView ID="FormView1" DataSourceID="AccessDataSource1" AllowPaging="true" runat="server"> <ItemTemplate> ProductID : <%# Eval("ProductID") %> </ItemTemplate> </asp:FormView> <asp:DataList ID="DataList1" DataSourceID="AccessDataSource1" runat="server"> <ItemTemplate> ...