Timer and gridview - asp.net

I want to display a online user indication in image item template of gridview inside a update panel which triggers by a timer in a certain time period. The image item template is getting image from a generic handler (.ashx) using a sql server database. the gridview is getting data from another sql server table which is inside an update panel as mentioned earlier. the problem is- when i login the main page from different browser (IE, Firefox,Chrome) in same pc the first browser which i login first, it is not displaying the latest user online indication. What should i do??? Plz help me.

Related

Return to same page state in ASP Web Pages (WebGrid)

I have created a page in ASP Web Pages with WebMatrix, where I use a WebGrid with paging to show the data from a query. I also have a search form on the top to search though the database. The rows are clickable, and when clicked it goes to a details page for that row, but when I go back, the WebGrid is reset. Is there any way to save the state of the webgrid, and eventually the filled search forms if they have been used, when I go back? It seems to me that when I just go back, without refresh, the page doesn't query the database again, because it is faster than refreshing. But the WebGrid is reset anyway to the first gridpage.
Can someone help?
I also noticed that WebGrid to go to its other pages. Does it retrieve all rows in the beginning or everytime in paging?

Force ASP.NET controls to reload data

I know there's a lot of information out there about how disabling ViewState will not prevent textboxes from persisting values across refreshes/postbacks. What I can't fins is information about how to circumvent this behavior.
Here's why I need to do this. I have a form that updates a db via AJAX. Every time a user changes a field, the db is updated immediately. Because of this, there's no reason to store values anywhere but the database.
Consider the following scenario.
User loads the page, textbox FirstName has a value of "Bob."
User changes first name to "Dave." (Database updates)
User clicks the refresh button.
We'd expect the FirstName box to now have the value of "Dave," but instead it shows "Bob." So how to force ASP to load the values from the db?
User clicks the refresh button.
On this step you'd re-read the data from the database and forcibly populate the controls with that data. If all of the "events" from the page are in fact handled by AJAX requests, then it sounds like the only two meaningful "WebForms events" are Page_Load and the Click handler for the "refresh" button. One of those two events should re-populate the controls from the database.
(Or is there no "refresh" button and the user is just reloading the page via browser functionality? In which case Page_Load should just always populate the controls from the database in this scenario.)
It seems the problem I was encountering had to do with creating and populating controls in during the correct page events. Fixed this by creating controls in Page_Init, and populating them in Page_Load.

Update asp.net datalist field, without refreshing , when value changes in database

I have an aspx page that shows a list of students in a databound datalist in card view layout ( i.e repeatcolumns = 5 and repeatdirection=horizontal ).
The properties displayed are - Student Name, Id and Status. The Status field is constantly updated by another external service.
Is it possible to show the new status of the particular student for whom the status has changed in the DB without having to refresh the entire page?
What i'm trying to achieve is a real time monitoring system that a tutor could use to view student activity in a lab.
Thanks
Arvind
You could use an update panel and then set a timer to refresh the update panel and re bind the datagrid with the new data.

update gridview and go back to the previous page

I have a gridview, getting data from sql server, there is an Edit link to get the detailed information for example, for a user from database.
this link open a new page with detailed information and when I click the updated button,I want to go back to the same page with that users informaton.
I set the page size to 10, it means I can see only 10 users per page,and if I click the edit link on page 25,and update the users info, I want to go back to page 25.
Should I use viewstate or gridview has any commnad to go back to the same page? the code is written in ASP.net C# sqlserver,
Thanks in advance
The gridview control will not provide this functionality.
Viewstate will only help persist data between postbacks of the same page (primarily).
Session state could be used to save the pagesize/pagenumber details onclick of the grideview edit before forwarding to the edit page. This can be re-processed back on loading of the view page.
My preference would be to store the values in the querystring. So on clicking edit, the pagesize and number are passed to the edit page (i.e edit.aspx?itemid=1&psize=10&pindx=25).
Then on finishing edit, the page number and size are based back to the view page for processing (view.aspx?psize=10&pindx=25)

preventing reinserting of data when press browser's refresh button

I developed a web application in asp.net.I have a module for saving values to database after clicking the button event.Thats working successfully.After that when i clicked the browser's refresh button the values reinserted to the table each time.How can i avoid this .Which is the code for this solution?
Here is a nice article on this
Preventing Duplicate Record Insertion on Page Refresh

Resources