asp.net gridview is fetching data too long - asp.net

it seems common issue so I am surprised I didn't find solution already, maybe someone can help me out.
I have a gridview that displays list of users of the app, this list is very big, and takes forever to load the data. Otherwise, data is paged through and once loaded everything goes fine. To help admins, I made search box and that works well.
Only issue is initial load of data, it seems that asp.net is retrieving all the records initially.
Is there a way to get only records for current page. Maybe there is a setting for gridview that I am missing or I am doing something else wrong.
Thank you in advance for suggestions.
Zeljko

you're going to have to do your own custom paging. Depending on your datasource you have to pass the PageIndex and size, to only get the pages results to be returned.
Ive used this run through before:
https://web.archive.org/web/20210510021915/http://aspnet.4guysfromrolla.com/articles/031506-1.aspx

Sounds like maybe you're using a Datatable/Dataset when you really want a Datareader. Alternatively, maybe I'm not understanding what you mean by "initial" and what you're experiencing is that you hit the jit compiler every time you do a new deployment.

Related

asp.net multiple user calculation error

Apologies if this has been asked/solved before. I've done a fair bit of searching but can't seem to find a direct answer to my problem.
I'm still very new to asp/vb coding.
I've created a complex calculator in asp.net using vb.net.
The user fills out a few text boxes with information then clicks the calculate button. The program then accesses an sql 2014 server to collect more information based on information the user has entered, then uses the information to run a few very complex calculations (I don't completely understand the calculations behind it).
It all works fine and is able to give the correct answer, the problem I've found is if there is more than one user accessing the site and they happen to click the calculate button within the same time, whoever clicked the calculate button first gets an error whilst the person who clicked second gets an answer.
I'm not sure if this is to do with how it accesses the sql database for information or if the information is somehow being overridden.
I was hoping this would be a common problem, but can't seem to find anything on it, at least I may not be asking the right question when searching.
Unfortunately for security reasons I'm not able to post any code for it (I'll see if I can get permission) but am hoping that someone has come across something similar and knows a work around. Maybe to have the site wait until the first round of calculations is complete before initiating the second round?
Thanks for your help in advance!
Please make sure that you should not use any shared variable in calculation because shared variables are common for all users. Also check for application variables.
I can understand, but if those public variable's value changed at one place, then after everywhere that variable's value will be new even if you are in middle of some processing.

SQL - Whole Records Being Cleared Out Through ASP.NET Web Forms Application

I'm part of a team building a large ASP.NET Web Forms application, and have recently gotten complaints that some records are being "cleared out" after being created -- in this case they create an "inventory" item, save it, and then perhaps after editing some of the data and re-saving, all of the fields are suddenly blank.
I realize that this could be some faulty logic on the save, in which case it will be difficult for you to offer insight, but we've never come across this particular issue before, and haven't really touched the logic. I'm wondering if anyone has some insight into what could possibly be going on, if it's possible that something sporadically happens on the client which makes the values of the input fields blank or unreadable...? I don't know, I'm a bit in the dark and frustrated because I can't reproduce the behavior, and we're losing a bunch of data.
Thanks in advance for any bit of direction or advice.
Related issues in WebForms are often caused by logic related to Page.IsPostBack and values being reset.
Without code it's hard to say; I'd suggest adding some temporary code to log the posted data (and function calls down the line to the database writes). Without logging you're blind.

WordPress Meta Data Being Corrupted, Deleted, or Altered

I've got a single meta variable with a string value that should always be 0 or 1 being stored on pages. I can set it using a simple dropdown box in a metabox and it seems to work great. For some bizarre reason, it sometimes gets changed from 1 to 0 seemingly randomly. I have no clue why, and it seems to happen even on a page I wasn't editing or updating. I'm baffled and don't even know where to begin looking because I haven't figured out how to replicate the problem.
Does anyone have any suggestions to search for a possible way to replicate this or figure out the cause?
IMO: That kind of bugs only can be catch debugging. Exists a tool called mtop that allows you see at all DB actions...
UPDATE
More easy is to log all queries in a period of time (until you see the malfunction) Here a related issue: Log all queries in mysql. Then you only need to look closer at update actions in the appropriate table. This can be done in windows or *nix. Good luck...

Easy way to replace Data with ComboBox? Or populate ComboBox from Data

I took over a very old project written in VB6, it's a mess and I don't really know VB so it would be great if someone could help me.
I have a Data control which gets records from an Access database which I would like to replace with some kind of drop down list - I thought about ComboBox. Unfortunately I cannot get records from the database in the same way as with Data, so I thought about populating ComboBox based on what's in the Data control. How can I achieve it? Or is there a better way to do it?
My last resort is to create all database methods manually in order to replicate Data's behaviour for ComboBox but I think it's too much effort for such a small change.
Thanks in advance!
The Data control does more than just let them browse through the records, it manages the database, current record, data binding, etc.
The easiest way to do what you want is to hide/move the data control and use its .Recordset.Find*() methods.
Note that DAO is archaic and has been supersceded at least once for VB6 (with ADO)

How to improve page loading delays?

I am using gridview control of .net framework 4.0. My list contains 1000 of rows which i am binding to a gridview on each postback. Hence, My page is taking time to load I want to speed up the system. Is there any other control available which can enhance the performance or is there any other way to achieve this?
What all i want is faster performance
You might be able to use faster controls, such as the Repeater, but it depends on what feature you really need. Are you only displaying the data or is it editable?
With such a large amount of data you can look at optimizing what HTML you use for rendering, as you may be able to split the page size by half...
First step should be to do a preformance check to find out what exacly is slow.
Check where in the code things take time, it could be one of many things.
1) If the control uses javascript, perhaps the users are on a old version of their browser with a slow javascript engine.
2) Perhaps the issue is bandwidth?
3) Perhaps its missing SQL index
and on it goes.
Dont guess at what is wrong, find out for sure what is taking the time, and solve then one at the time.
Like Forgotten Semicolon suggested loading via Ajax might be solution, it would give the user a better idea what is going on.
Other then that i would would heavly suggest caching if posible, you can use the built in Cache options to cache the datatable.
In addition to the point about not binding on every postback, I am assuming the datasource is an SQL database. You should probably check to see how fast the query runs. Make sure you have properly indexed your tables.

Resources