title: ASP.NET Gridview Loading Slower with more data bindings
body: <p>I am using Visual Studio 2010 and SQL Server 2008 and populating my gridview with sqldatasoure .And inside itemtemplate of gridview there are some dropdownlist which are again being binded with sqldatasource and on rowdatabound event am assigning selected values for these dropdownlist. There are nearly 2000+ records which makes grid to load very slower. Any ideas for optimizing this. </p>
  
  <pre><code>  &lt;form id="form1" runat="server"&gt;
    &lt;div&gt;
    &lt;asp:GridView ID="Gridview1" runat="server" DataSourceID="SqlDataSource1" 
        AutoGenerateColumns="False" onrowdatabound="Gridview1_RowDataBound"&gt;
          &lt;Columns&gt;
              &lt;asp:TemplateField&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:DropDownList ID="Dropdownlist1" runat="server" DataSourceID="SqlDataSource2" DataTextField="empid" DataValueField="empname"&gt;
                      &lt;/asp:DropDownList&gt;
                      &lt;asp:HiddenField ID="HiddenField1" runat="server" Value='&lt;%# Eval("empid") %&gt;' /&gt;
                      &lt;asp:DropDownList ID="Dropdownlist2" runat="server" DataSourceID="SqlDataSource3" DataTextField="desgid" DataValueField="desgname"&gt;
                      &lt;/asp:DropDownList&gt;
                      &lt;asp:HiddenField ID="HiddenField2" runat="server" Value='&lt;%# Eval("desgid") %&gt;' /&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
          &lt;/Columns&gt;
      &lt;/asp:GridView&gt;
  &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString='&lt;%$     ConnectionStrings:dbconn %&gt;'
      SelectCommandType="StoredProcedure" SelectCommand="SP_Fetch_Grid"&gt;    &lt;/asp:SqlDataSource&gt;
      &lt;asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString='&lt;%$ ConnectionStrings:dbconn %&gt;'
      SelectCommandType="StoredProcedure" SelectCommand="SP_Fetch_DDL1"&gt;&lt;/asp:SqlDataSource&gt;
      &lt;asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString='&lt;%$ ConnectionStrings:dbconn %&gt;'
      SelectCommandType="StoredProcedure" SelectCommand="SP_Fetch_DDL2"&gt;&lt;/asp:SqlDataSource&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  
  protected void Gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
  {
      if (e.Row.RowType == DataControlRowType.DataRow)
      {
          HiddenField hf1 = (HiddenField)e.Row.FindControl("HiddenField1");
          HiddenField hf2 = (HiddenField)e.Row.FindControl("HiddenField2");
          DropDownList ddl1 = (DropDownList)e.Row.FindControl("DropDownList1");
          DropDownList ddl2 = (DropDownList)e.Row.FindControl("DropDownList2");
          ddl1.SelectedValue = hf1.Value;
          ddl2.SelectedValue = hf2.Value;
      }
  }
  </code></pre>