Must leave the page and return to get the page to update

  • Thread starter Thread starter Cal Who
  • Start date Start date
C

Cal Who

I have a data bound asp:DataList such that if a file exist the asp:DataList
shows some data from the file.

If there is no file it lists nothing.


I also have a button to upload a file.

When the button is clicked the file is uploaded but the asp:DataList is not
refreshed.

I assume the data bound controls are run before the button event is.

Is there some way I can cause the asp:DataList to reload it's data?



Failing that.

I added a refresh button in which onclick contains: window.location...

In web.config I have
<caching>

<outputCache enableOutputCache="false"

enableFragmentCache="false"

sendCacheControlHeader="false"

omitVaryStar="false" />

</caching



I believe when the button is clicked it refreshes the page (becaue I see
flicker) but the asp:DataList does not update.

If in FF I use "Clear recent history" to clear the cache and then click the
refresh button the asp:DataList still does not update.



If I leave the page and returnto it, it updates nicely.


I don't know what to try next.

Can you suggest something?


Thanks
 
I have a data bound asp:DataList such that if a file exist the asp:DataList
shows some data from the file.

If there is no file it lists nothing.

I also have a button to upload a file.

When the button is clicked the file is uploaded but the asp:DataList  is not
refreshed.

I assume the data bound controls are run before the button event is.

Is there some way I can cause the asp:DataList to reload it's data?

Failing that.

I added a refresh button in which onclick contains: window.location...

In web.config I have
<caching>

<outputCache enableOutputCache="false"

enableFragmentCache="false"

sendCacheControlHeader="false"

omitVaryStar="false" />

</caching

I believe when the button is clicked it refreshes the page (becaue I see
flicker) but the  asp:DataList  does not update.

If in FF I use "Clear recent history" to clear the cache and then click the
refresh button the asp:DataList still does not update.

If I leave the page and returnto it, it updates nicely.

I don't know what to try next.

Can you suggest something?

Thanks

I think you simply need to bind your list again after the file has
been uploaded

Sub ButtonUpload_Click(sender As Object, e As EventArgs)

FileUpload()
BindDatalist()

End Sub
 
Alexey said:
I think you simply need to bind your list again after the file has
been uploaded

Sub ButtonUpload_Click(sender As Object, e As EventArgs)

FileUpload()
BindDatalist()

End Sub


I think you're right :-)

I think I just thought that binding simply pointed to the source.
Now it seems to that it cause the source to be read.


Thanks a lot
 
I think you're right :-)

I think I just thought that binding simply pointed to the source.
Now it seems to that it cause the source to be read.

Thanks a lot

I think the problem is that you bind the list in Page_Load and then
the "ButtonUpload_Click" fired. If yes, you may change Page_Load like

If Not Page.IsPostBack Then
BindDatalist()
End If

So that it will not happen twice during postback

Hope this helps
 
Alexey said:
I think the problem is that you bind the list in Page_Load and then
the "ButtonUpload_Click" fired. If yes, you may change Page_Load like

If Not Page.IsPostBack Then
BindDatalist()
End If

So that it will not happen twice during postback

Hope this helps

<asp:DataList runat="server" .snip. DataSourceID="ObjectDataSourcePng">

<ItemTemplate>

<%# Container.DataItem %>

</ItemTemplate>

</asp:DataList>

and

<asp:ObjectDataSource ID="ObjectDataSourcePng" runat="server"
TypeName="PhotoManager"
SelectMethod="ListImportPngDirectory"></asp:ObjectDataSource>

and
ListImportPngDirectory returns an array of FileSystemInfo.

I never actually bind. I guess the DataList does that. Right?

Is the DataList iterating the FileSystemInfos Array?

Or the DataSource?
So how is the FileSystemInfos converted to string.

By the DataSource or the Datalist?

Very confusing.

Anyway, your fix made it work,



Thanks again
 
<asp:DataList runat="server" .snip. DataSourceID="ObjectDataSourcePng">

<ItemTemplate>

<%# Container.DataItem %>

</ItemTemplate>

</asp:DataList>

and

<asp:ObjectDataSource ID="ObjectDataSourcePng" runat="server"
TypeName="PhotoManager"
SelectMethod="ListImportPngDirectory"></asp:ObjectDataSource>

and
ListImportPngDirectory returns an array of  FileSystemInfo.

I never actually bind. I guess the DataList does that. Right?

Is the DataList iterating the FileSystemInfos Array?

Or the DataSource?
So how is the FileSystemInfos converted to string.

By  the DataSource or the Datalist?

Very confusing.

Anyway, your fix made it work,

Thanks again- Hide quoted text -

- Show quoted text -

ok, I see,

You probably should add

ObjectDataSourcePng.Update();

to the method where you upload the file
 
Alexey said:
ok, I see,

You probably should add

ObjectDataSourcePng.Update();

to the method where you upload the file

But then I would have to know what to do to cause the display to be updated.

I could just call an update routine and do the Bind in there.

Is there some reason why that would be better?


Binding in that upload method like you first suggested appears to work find.

I'm assuming that binding is much like assigning a value to a variable.

That is, the previous bind effects are erased and replaced by the new stuff.
Right?


Thanks
 
Back
Top