I have a repeater with a paged datasource on a content page in dotnet 4.0 coded with c# behind. The data is loaded via a hashtable that pulls data from an sql 2005 database on a shared server. Currently the first time the page loads, no data shows and/or the repeater fails to show. If I refresh the page though the data displays fine.
Has anyone else come across this sort of problem before? Ideally I'd like to prevent the page from rendering until the data is loaded in but haven't been able to find a solution.
I can provide code and links to project for anyone interested in this problem.
Thanks
Si
Sound like you're binding the information at the wrong time? Can't be sure without code.
It's ok I fixed it. I was populating the repeater with data based on the value of a session object that isn't created until after the page has loaded. School boy error really.
Related
I have this issue with Crystal Reports in which paging buttons don't navigate past page 2. Here is my scenario:
ASP.NET 4.0 project
CR Developer Version 13 SP16
Data source is cached in session throughout page loads
Report is controlled via filters on ASPX page
Filter values are passed on to a stored procedure on the DB itself at databind
I have already gone through other similar posts both here and on the internet which basically tell me to move report initialization from Page_Load to Page_Init, but there's a difference here: on Page_Init, I don't have access to the filters allowing me to control the report yet, which means I can't query them for filter data. I have also tried other things, including enabling viewstate and moving report binding to the Navigate event, but to no avail. Thoughts?
Never mind, I fixed it myself by passing the parameters via session. It's crude and I had to remove autopostback functionality in the process, but it works.
I have a HTML page in my project location and I am trying to populate values from my c# script to the place holder in HTML page. But every first time when i was running the script values got populated with correct details, but in the second run when i am changing my values like my name salary then HTML page doesn't reflect this new value and old data got appeared. Please suggest
Your question doesn't really explain much, in particular which technology your utilizing. It appears as if you lack an understanding of:
View State
Viable information can be found here. In an Web-Form application, you'll not only need to account for persistence of the View State, but the Page Life Cycle as well. It will play an important role in understanding the fundamentals.
You stated the following:
The first time the page loads the data exist, when I update the data
the old data exist rather than the new data.
Your issue could stem from either a Postback or the control your utilizing. When a Postback occurs, it means exactly what it states, a Client's interaction with your application transmits data back to the server.
You can remedy such a problem with:
Update Panel
Page.IsPostback
Databind();
Ajax
The problem has viable solutions, however until you truly understand the problem we can't specifically help you remedy the issue. This should point you in the proper direction though.
GridView in my ASP.NET application is working very slowly when changing pages. I know that this is most probably caused by a lot of data being pooled out of database each time page is updated but I don’t know how to fix this since I’m not to ASP.NET.
My current configuration is GridView with ObjectDateSource and paging enabled. I don’t have any code behind or anything similar. ObjectDataSource is bined to typed data set.
You are correct about the cause of this – it’s the fact that you have to get all the data from database even if you only want to display one small part. For example, you retrieve 5000 rows from DB only to display 15 rows in current page.
Solution for this is implementing custom paging.
In order to get this to work with your current configuration you’ll need to update your current select method to accept the starting index and maximum number of rows input parameters and also update following properties in your grid view
“StartRowIndexParameterName”, “MaximumRowsParameterName”, “SelectCountMethod”.
Here is a great article that covers what you need but there are also a lot of topics here on StackOverflow that cover this topic.
I found the same problem and implemented a custom gridview which is now opensource, you can find it here https://github.com/vcliment89/GridViewEX. You don't need to implement all the gridview but there's an example of a custom pager on the demo project.
I wrote a page which user can input a name and get some infos from the database. In the .cs file I got the texts from the database and assigned them to the labels and in the debugging mode, the labels did change their texts. BUT I don't know how to update them in the same page. I used some ways to update the page, but it updated the whole page and display nothing in the labels.
How can I achieve this function?
I google it and found the AJAX is a good way, but it's an emergency i have no time to learn AJAX?
does someone have good idea to help me solve it?
Thanks a lot!
What you're talking about is a postback. When the page posts back to the server, the page is refreshed.
If you want to set the labels and avoid losing the data with a postback, you can do so through an ajax call in your JavaScript code, you can set hidden fields or you can set the values in the Session object (not the best idea). There are numerous ways around this; you just have to pick one.
Do some reading on ajax (it's not as hard as you think). You can call the server through ajax, which will get the data from the Db and return it to your JavaScript as JSON. You can then use that to fill your labels.
You may want to look into an UpdatePanel as well. They aren't the fastest solution available, but they are very easy to implement.
I am attempting to create a store page, and for the storefront page I need to create something that will
list items from the database,
get the ID + Image URL saved in the database
create an hyperlinked image for each item in the query.
Any suggestions on how to do this?
The hyperlinked image will be an image of a product and links to a store page based on ID.
and a list of them will be displayed for the person to click on.
Thank you in advance, this project is a first for me (as well as my first web application in asp.net) and I'd like to see it done right!
And the site is done in C#, although if necessary I can port over to VB, at this time, not much actual code behind has been written, and I am comfortable enough with both to port whatever code I have over to it)
A simple approach would be to use an ASP.NET repeater.
Class documentation is here: http://msdn.microsoft.com/en-us/library/w9283stf
One detailed (although potentially out-of-date) article I found with a quick search is http://msdn.microsoft.com/en-us/magazine/cc163780.aspx
(But there are plenty of other "how to use repeater control" articles out there).
Good luck.