CookieParameter/SQLDataSource driving GridView load out of sync

Last post 02-16-2007 2:40 PM by Woodman. 2 replies.

Sort Posts:

  • CookieParameter/SQLDataSource driving GridView load out of sync

    02-13-2007, 3:05 PM
    • Loading...
    • Woodman
    • Joined on 02-13-2007, 2:22 PM
    • Posts 9

    I have been fighting this for an embarrasing amount of time and need some help. Here is the scenario: I have two dropdowns and a Gridview embedded inside a Panel. I want updates to be chained. In other words...

     1. Select Item from dropdown#1 (w/AutoPostBack), then inside "SelectedIndexChanged" event: Dropdown#2 gets loaded, the first item is selected, CookieParameter to SQLDataSource "FilterParameter" is set to the new value in Dropdown#2.

    Results: The grid gets populated, but the FilterParameter is not applied to the GridView for the currently selected item in DD#2. If I Refresh the page again then the Filter is applied. If I change the item in DropDown#2 (w/AutoPostBack) then the Gridview always populates with the prior item, not the currently selected one. It's like the Gridview is always seeing the previous CookieParameter, not what is currently in DD#2.

    I was forced to use the CookieParameter because the DD#2 ControlParameter was falling out of scope with the Gridview I think because of the Panel the Gridview is buried in.

     Attempted Remedies:

     I have reset the CookieParameter in the PreRender event of the grid, and many other events, but it still doesn't work. Does anyone know how I can ensure that the latest item selected in DD#2 gets applied to the GridView data being returned?

     

    Thanks!

    Tom

  • Re: CookieParameter/SQLDataSource driving GridView load out of sync

    02-16-2007, 9:27 AM
    • Loading...
    • eodops
    • Joined on 05-05-2006, 10:52 AM
    • Posts 2

    Are you re-binding the datagrid in your selected index change? Are you passing the dd#2 parameter value to your gridview datasource? Just some things to look at.

     

    Jon

  • Re: CookieParameter/SQLDataSource driving GridView load out of sync

    02-16-2007, 2:40 PM
    • Loading...
    • Woodman
    • Joined on 02-13-2007, 2:22 PM
    • Posts 9

    Does re-binding equate to DataBind() or something else? I have placed a gv.DataBind() call in the SelectedIndexChanged but it still did not have the right parameter value. I am passing the value for the parameter through a CookieParameter within the SelectedIndexChanged also. Still seems to not apply to the current refresh of the page. BTW, what is the best way to just force a refresh of a page?

    It may help if I explain that I am using nested masterpages. I have a top level .master page and then another master page below with a content page below that. I learned that when you do this the Content sections in the content page lose scope with other content sections, so in other words I can only update a control in another Content section using some accessibility code. I found code to do this, but I'm wondering if the sync problems have to do with scope? This doesn't make sense to me but thought I would ask.

    Thanks,

    Tom

Page 1 of 1 (3 items)
Microsoft Communities
Page view counter