Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to refresh only datagrid portion of .ASPX page? 2

Status
Not open for further replies.

szfq93

Programmer
Jul 12, 2002
11
US
I have a web page in ASP.NET that is set to refresh every x seconds. This page contains a datagrid (and a few other items) that shows records from an SQL Server 2000 database table.

The problem is that the whole page refreshes every time and is annoying to the user. I NEED to refresh so that new records in the databae show up on the web page. Is there a way for me to only

refresh the datagrid?

So far, I've got the following ideas:
1. - use remote scripting?
2. - use XMLHTTP?
3. - use a frame within a frame?


Any suggestions?
 
szfq93: This is a shot out of the dark, but here goes. You could have your datagrid on a separate aspx page, and call that page, then you'd be posting back and recieving that page only, calling it using an "src" type tag.

I don't see how you could regenerate the grid on the aspx page you have without posting back the page itself.
 
I haven't look deeply into this area myself but Caching might be able to accomplish what you want. Simply cache everything except the datagrid. Then when the page refreshes only the data grid will refresh. Like I said I have looked deeply at the subject at all but I think that may work for you. That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Zarc: Nice argument - didn't dawn on me that caching would prevent the aspx page from "reloading". My answer wasn't all that clear, but what I was trying to argue is that, in a few of my aspx pages, I call for a chart to be updated, and this chart sits in its own aspx page, and is linked to an src tag on the current aspx page, so I just change parameters on the page, then call the chart aspx page that simply reloads the chart (the chart has VB in its code, so the chart re-loads, and then returns to the current aspx page with the latter staying put. I think I'll test this out and your caching procedure and post back. Good question here by szf.
 
Good info, thanks guys. I'm going to try both ideas. Let me provide more info on my aspx page:

-there are actually two datagrids but both use the same dataset. I separate the data using a filter. The first grid shows "new data" while the second grid shows "the rest". It's the "new data" grid that must be refreshed frequently because the user only has three minutes to respond to each new record (before the data expires).

-the page is (pretty much) nothing more than these two grids, so caching will probably help only a little.


I'll keep everybody posted as things progress, thanks!
 
I was thinking of using IFRAME and putting the grid in the frame. Any thoughts on that?
 
Isadore, could you provide more detail on how to use the SRC? I'm guessing that, in your case, your chart was an image? How could I use SRC to point to another web page?

Thanks again.
 
sz: I'm going to test it this morning, will get back to you.
 
Iframe should do something similiar to Izy's src code I think. Like I said before I haven't worked a great deal in this area of .NEt as of yet. In fact I am doing a side project in Access at the moment. That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Zarc: Thanks; will evaluate - this is a great question presented by szf - we'll have something on this at some point today - like you, tied up at the moment.
 
All attempts, at least from my efforts, failed, either though an http/src/etc tag or otherwise, to call an "aspx" page from within an "aspx" page - this works for binary streams that redraw images but no luck here.

Zarc might be on the right track with Iframe. More research needed on this - great question.
 
I, myself, have been tied up with other projects. I plan on playing with the Iframe idea later this week (hopefully!).

One trick I've heard is to use a frame within a frame - but I don't know if this is feasible or even necessary with .NET.
 
szf: One way or another we'll probably solve this in the next few days. I think everyone is tied up this week. I'll follow suit too with the Iframe (nested sounds like a good possibility).
 
szf: Finally got time to look into the IFrame suggestion by Zarc (stands for "inline frame").

It will work, I tested it with an Datagrid and updated the grid with the parent aspx page remaining in place and not posting back.

The syntax for the Iframe is:

<iframe src=&quot;<%=URL%>&quot; width=&quot;400px&quot; height=&quot;400px&quot;/>

...where the string &quot;URL&quot; is altered in the code. I did a querystring postback to &quot;update&quot; the datagrid and it worked beautifully. You might want to do some research to see if there are any limitations that may hinder you from using the IFrame but it does work with IE v. 6.

Good luck.
 
One additional note. The URL was a single aspx page with only the Datagrid catching the changed variables via Querystring.
 
I'm confused. So the querystring is passed to the iframe via the src attribute, or the datagrid picks up the &quot;parent&quot; querystring from the main page?

What does the resulting source look like when you do this:
Code:
<iframe src=&quot;<%=URL%>&quot; width=&quot;400px&quot; height=&quot;400px&quot;/>

??
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
The source would be something like this.
<iframe src=&quot; width=&quot;400px&quot; height=&quot;400px&quot;/>

the page gridpage.aspx would simply look at the querystring to get its data. I am sure you know something of IFrames Paul. They just float ontop of the page using absolute positioning. A good tutorial can be found here for anyone unsure of them.

That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Yep, that answers it. Very nice, indeed. :)
penny1.gif
penny1.gif

The answer to getting answered -- faq855-2992
 
Zarc. Danke fue Sie *. It was your &quot;ah ha&quot;; good job.
 
What is fue Sie *. I know Danke is Thank you.
My &quot;ah ha&quot;??

Boy I have to get to bed earlier than 4 tonite. I can't think straight.

Your welcome I think. That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top