Link to home
Start Free TrialLog in
Avatar of Mohammad Alsolaiman
Mohammad AlsolaimanFlag for Saudi Arabia

asked on

Why does it take much more time binding data to gridview

Hi;
here is my story
--Total Record -- 5000 records  
---Bringing Data from Database using lambda expression....
var dtTable = objHRContext.BscTbls.Select(X => X ).ToList ();  

Open in new window

 
--it takes 0 second bringing data from database.....
--binding  Data to gridview  with DataTable it takes 10 seconds... Here is my problem
 
 gvData.DataSource = dtTable;
  gvData.DataBind();

Open in new window

--Here is  my GridView Design view

 <asp:GridView ID="gv_EmpList"   runat="server" AutoGenerateColumns="False"
                    class="table table-striped" Width="100%">
                    <Columns>
                      
                        <asp:BoundField DataField="BscName" ItemStyle-Wrap ="true" HeaderStyle-Wrap ="true"  HeaderText="الاسم" />
                        <asp:BoundField DataField="RankDescription" HeaderStyle-Wrap ="true" HeaderText="grade" />
                        <asp:BoundField DataField="BscRank_Type_Desc" HeaderStyle-Wrap ="true" HeaderText="grade type" />
                         <asp:BoundField DataField="Unit_Name" ItemStyle-CssClass ="styleDisPlay" HeaderStyle-CssClass ="styleDisPlay" HeaderStyle-Wrap ="true" HeaderText=" grade type " />
                        <asp:BoundField DataField="BscNo" HeaderStyle-Wrap ="true"  HeaderText="emp number" />
                        <asp:BoundField DataField="LastPromDate" HeaderStyle-Wrap ="true" HeaderText="promotion date" />
                        <asp:BoundField DataField="Billet_Name" HeaderStyle-Wrap ="true" ItemStyle-Wrap ="true" HeaderText="billet" />
                        <asp:BoundField DataField="SpecialityDesc" HeaderStyle-Wrap ="true" ItemStyle-Wrap ="true" HeaderText="job tasks" />
                        <asp:BoundField DataField="EducationName" HeaderStyle-Wrap ="true" ItemStyle-Wrap ="true" HeaderText="qualification" />                    
                    </Columns>
 </asp:GridView>


--calling my JQuery DataTables binding to Gridview

  function BindDataTable() {            $('[id*=gv_EmpList]').prepend($("<thead></thead>").append($('[id*=gv_EmpList]').find("tr:first"))).DataTable({
                "responsive": true,
                "sPaginationType": "full_numbers",
                "info": false,
                "ordering":false,
                "bLengthChange": false,
                "oLanguage":
                {
                    "sSearch": "<b>search:</b>",
                    "sLengthMenu": "text _MENU_ ",
                    "oPaginate":
                     {
                         "sPrevious": "previous",
                         "sNext": "next",
                         "sLast": "last",
                         "sFirst": "first "
                     }
                }
            });       }

Open in new window

help me please, & thanks in advance
Avatar of Pratik Somaiya
Pratik Somaiya
Flag of India image

Try using:

gridHeader.ColumnHeadersVisible = false;

Open in new window


Parsing the columns takes time, the above may help to reduce the time.

Please try and let me know
Avatar of Mohammad Alsolaiman

ASKER

I'll try it now
sorry my friend, but I have no such property "ColumnHeadersVisible"!
You need to add it, for detailed information on this property, you can go to below link:

https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.datagridview.columnheadersvisible?view=netframework-4.7.2
sorry my friend, I'm using asp.net web gridview control, & I think this property ".ColumnHeadersVisible " is for window form.
Do you have sort on?  SortExpression="fieldName" maybe this is causing it to index the data when it loads.
I had try "SortExpression" my friend, and I had encountered the same delay issue.
I had try repeater and it was good to me. it consume one second only.
thank u very much jshesek, and all participated persons.
ASKER CERTIFIED SOLUTION
Avatar of Mohammad Alsolaiman
Mohammad Alsolaiman
Flag of Saudi Arabia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You see, I had try there solutions but it doesn't fit to my case at all. Thanks to all participated experts for there trying to help me.