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

Discussion in 'ASP .Net' started by Cal Who, Jan 30, 2010.

  1. Cal Who

    Cal Who Guest

    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
    Cal Who, Jan 30, 2010
    #1
    1. Advertising

  2. On Jan 30, 4:41 pm, " Cal Who" <> wrote:
    > 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 Smirnov, Jan 30, 2010
    #2
    1. Advertising

  3. Cal Who

    Cal Who Guest

    Alexey Smirnov wrote:
    > On Jan 30, 4:41 pm, " Cal Who" <> wrote:
    >> 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



    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
    Cal Who, Jan 30, 2010
    #3
  4. On Jan 30, 5:56 pm, " Cal Who" <> wrote:
    > Alexey Smirnov wrote:
    > > On Jan 30, 4:41 pm, " Cal Who" <> wrote:
    > >> 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

    >
    > 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 Smirnov, Jan 30, 2010
    #4
  5. Cal Who

    Cal Who Guest

    Alexey Smirnov wrote:
    > On Jan 30, 5:56 pm, " Cal Who" <> wrote:
    >> Alexey Smirnov wrote:
    >>> On Jan 30, 4:41 pm, " Cal Who" <> wrote:
    >>>> 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

    >>
    >> 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


    <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
    Cal Who, Jan 30, 2010
    #5
  6. On Jan 30, 7:24 pm, " Cal Who" <> wrote:
    > Alexey Smirnov wrote:
    > > On Jan 30, 5:56 pm, " Cal Who" <> wrote:
    > >> Alexey Smirnov wrote:
    > >>> On Jan 30, 4:41 pm, " Cal Who" <> wrote:
    > >>>> 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

    >
    > >> 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

    >
    > <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 Smirnov, Jan 31, 2010
    #6
  7. Cal Who

    Cal Who Guest

    Alexey Smirnov wrote:
    > On Jan 30, 7:24 pm, " Cal Who" <> wrote:
    >> Alexey Smirnov wrote:
    >>> On Jan 30, 5:56 pm, " Cal Who" <> wrote:
    >>>> Alexey Smirnov wrote:
    >>>>> On Jan 30, 4:41 pm, " Cal Who" <>
    >>>>> wrote:
    >>>>>> 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

    >>
    >>>> 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

    >>
    >> <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


    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
    Cal Who, Feb 1, 2010
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gianmaria I.

    User can leave the page?

    Gianmaria I., May 24, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    331
    Gianmaria I.
    May 24, 2004
  2. Callback on page leave

    , Jul 31, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    355
    bruce barker \(sqlwork.com\)
    Jul 31, 2006
  3. xzzy
    Replies:
    2
    Views:
    350
  4. NeoGeoSNK
    Replies:
    25
    Views:
    890
    NeoGeoSNK
    Nov 24, 2006
  5. Replies:
    2
    Views:
    442
Loading...

Share This Page