Which is good way to bind more than 10000 records with sql?
first way By using java script
or
se开发者_JAVA技巧cond way By using Data sourse in asp.net sqldatasourse
which is taking less stress while loading the data.. into webpage
It's a horrible idea to bind 10000 records into a web page. Sensible solutions do paging; i.e. they display a subset of the data and then let the user page up/down in it.
In response to sikender's comment
ya.. i knew paging is there... but its for viewing ... the data.. in page mode.. but i want to bind this type of data with datagrid..by using which method. tell me which method.. i mention two method .. above.. which one is better and how.. tell me.. pls
Asynchronous javascript call may seems to be less stress since client will able able to see page partial loaded follow by its data.
You'll probably want to page the data, depending on how you're doing it you could do it either ways, with javascript or .net sqldatasource.
if you're not concerned about users having javascript capabilities i'd use javascript to load the data for a better user experience.
here is an example on how to use the ajax:Grid to page data with no postback.
http://dotnetslackers.com/articles/ajax/ASPNETAjaxGridAndPager.aspx
Why you want to bind ur datagrid by using javascript approach?
Why not using a datatable?
//some code snippet
e.g.
datatable myDt = getTheDataSourceFromDatabase();
if(myDt != null && myDt.rows.count > 0)
{
myDatagrid.datasource = myDt;
myDatagrid.databind();
}
If you need asynchronous response, use Update panel.
Using javascript approach has many pitfalls
a) Clients can disable the JavaScript of the browser
b) Sql injection as you cannot use stored proc while accessing thru javascript unless you are using native ajax etc. to list a few
For this reason heavy database manipulation are done at the server-side.
Else it is better to do paging.. You don't have to bring all the records from the database at a time. Write a stored proc which will accept the start and endpage limits and will fetch the record(use row_number() function
).Alternatively, use LINQ
to do the same (via Take & Skip
)
e.g. a) Using Take and Skip method in LINQ queries
b) Custom Paging in GridView Using LINQ
精彩评论