Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
DotNetJunky #1
UserControl inside of datagrid - loses its viewstate when datagrid is re-bound on postback
I have a simple usercontrol, a datepicker which contains 3 dropdownlist , it
resides inside a datagrid column and i set the selecteddate property of the
usercontrol from one of the DataBinder.Eval 's ... everythign works fine.
The datepicker also works fine on a regular page, and will normally persist
its viewstate on a page.postback event. However now i am trying to use it in
a datagrid and running into problems.
When the datagrid is re-bound on postback or it's selectedIndexChanged
event, the usercontrol's dropdowns become empty. It isnt saving it's
viewstate and i cant figure out why.
Can someone point me to the right direction of how to persist the state of a
usercontrol's dropdownlists on re-bind of the datagrid?
Inside the usercontrol i am viewstating the properties of it, IE, the
selecteddate, selectedday/month/year , etc. Everything is viewstated with a
prefix of this.ID + "_" + propertyvalue.
Thanks in advance,
- DNJ
DotNetJunky Guest
-
Get controls values upon auto-postback of another control inside DataGrid
Hi This is edited from post from a while back, there's still something I need to find an answer for (boy datagrids are a headache when you first... -
custom usercontrol inside of datagrid - loses its state/viewstate on re-bind/postback of the datagrid
I have a simple usercontrol, a datepicker which contains 3 dropdownlist , it resides inside a datagrid column and i set the selecteddate property of... -
DataGrid empty on Postback with ViewState enabled
Hi there! I'm having a problem with the datagrid control. I can't seem to get the datagrid to restore it's contents from ViewState. A... -
viewstate of the user control inside datagrid...
Hi there! I have datagrid with template column and I am using the same user control for display (in ItemTemplate) and collect (in EditItemTemplate)... -
Problem with UserControl Property in a DataGrid after Postback
Hello, I have this page.aspx ---------- <%@ Register TagPrefix="uc1" TagName="Userdetails" Src="Userdetails.ascx" %> ... <asp:datagrid... -
Brock Allen #2
Re: UserControl inside of datagrid - loses its viewstate when datagrid is re-bound on postback
You should only load (DataBind) the DataGrid when IsPostBack is false. So
don't do it in every request. Rebuilding it every time flushes the ViewState
and thus all the behavior is going to not work as you've noticed.
-Brock
DevelopMentor
[url]http://staff.develop.com/ballen[/url]
> I have a simple usercontrol, a datepicker which contains 3
> dropdownlist , it resides inside a datagrid column and i set the
> selecteddate property of the usercontrol from one of the
> DataBinder.Eval 's ... everythign works fine. The datepicker also
> works fine on a regular page, and will normally persist its viewstate
> on a page.postback event. However now i am trying to use it in a
> datagrid and running into problems.
>
> When the datagrid is re-bound on postback or it's selectedIndexChanged
> event, the usercontrol's dropdowns become empty. It isnt saving it's
> viewstate and i cant figure out why.
>
> Can someone point me to the right direction of how to persist the
> state of a usercontrol's dropdownlists on re-bind of the datagrid?
>
> Inside the usercontrol i am viewstating the properties of it, IE, the
> selecteddate, selectedday/month/year , etc. Everything is viewstated
> with a prefix of this.ID + "_" + propertyvalue.
>
> Thanks in advance,
>
> - DNJ
>
Brock Allen Guest
-
DotNetJunky #3
Re: UserControl inside of datagrid - loses its viewstate when datagrid is re-bound on postback
Brock, The only time i am re-binding the datagrid is when PageIndexChanged
(requred for paging unless i am mistaken - IE, you set the newpageindex and
then call databind to show the new page) as well as when rows are deleted or
updated. Most importantly i need this fixed for when rows are deleted...
I am doing a check for page.ispostback on page_load and doing the initial
databind() there, however i also fire the databind() on the events mentioned
above.
Thanks,
- DNJ
"Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
news:128369632470051255114592@msnews.microsoft.com ...> You should only load (DataBind) the DataGrid when IsPostBack is false. So
> don't do it in every request. Rebuilding it every time flushes the
> ViewState and thus all the behavior is going to not work as you've
> noticed.
>
> -Brock
> DevelopMentor
> [url]http://staff.develop.com/ballen[/url]
>
>
>>>> I have a simple usercontrol, a datepicker which contains 3
>> dropdownlist , it resides inside a datagrid column and i set the
>> selecteddate property of the usercontrol from one of the
>> DataBinder.Eval 's ... everythign works fine. The datepicker also
>> works fine on a regular page, and will normally persist its viewstate
>> on a page.postback event. However now i am trying to use it in a
>> datagrid and running into problems.
>>
>> When the datagrid is re-bound on postback or it's selectedIndexChanged
>> event, the usercontrol's dropdowns become empty. It isnt saving it's
>> viewstate and i cant figure out why.
>>
>> Can someone point me to the right direction of how to persist the
>> state of a usercontrol's dropdownlists on re-bind of the datagrid?
>>
>> Inside the usercontrol i am viewstating the properties of it, IE, the
>> selecteddate, selectedday/month/year , etc. Everything is viewstated
>> with a prefix of this.ID + "_" + propertyvalue.
>>
>> Thanks in advance,
>>
>> - DNJ
>>
>
>
DotNetJunky Guest
-
Brock Allen #4
Re: UserControl inside of datagrid - loses its viewstate when datagrid is re-bound on postback
Ah, ok... hmm... Well, then when you rebind the DataGrid do you do it via
the Page.DataBind() or do you do it directly on the DataGrid control? If
you do it Page wide then you might be blasting the entries in the DropDownList.
When you debug this, in your SelectedIndexChange event does the DDL have
all of its items?
-Brock
DevelopMentor
[url]http://staff.develop.com/ballen[/url]
> Brock, The only time i am re-binding the datagrid is when
> PageIndexChanged (requred for paging unless i am mistaken - IE, you
> set the newpageindex and then call databind to show the new page) as
> well as when rows are deleted or updated. Most importantly i need
> this fixed for when rows are deleted...
>
> I am doing a check for page.ispostback on page_load and doing the
> initial databind() there, however i also fire the databind() on the
> events mentioned above.
>
> Thanks,
> - DNJ
> "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
> news:128369632470051255114592@msnews.microsoft.com ...
>>> You should only load (DataBind) the DataGrid when IsPostBack is
>> false. So don't do it in every request. Rebuilding it every time
>> flushes the ViewState and thus all the behavior is going to not work
>> as you've noticed.
>>
>> -Brock
>> DevelopMentor
>> [url]http://staff.develop.com/ballen[/url]>>> I have a simple usercontrol, a datepicker which contains 3
>>> dropdownlist , it resides inside a datagrid column and i set the
>>> selecteddate property of the usercontrol from one of the
>>> DataBinder.Eval 's ... everythign works fine. The datepicker also
>>> works fine on a regular page, and will normally persist its
>>> viewstate on a page.postback event. However now i am trying to use
>>> it in a datagrid and running into problems.
>>>
>>> When the datagrid is re-bound on postback or it's
>>> selectedIndexChanged event, the usercontrol's dropdowns become
>>> empty. It isnt saving it's viewstate and i cant figure out why.
>>>
>>> Can someone point me to the right direction of how to persist the
>>> state of a usercontrol's dropdownlists on re-bind of the datagrid?
>>>
>>> Inside the usercontrol i am viewstating the properties of it, IE,
>>> the selecteddate, selectedday/month/year , etc. Everything is
>>> viewstated with a prefix of this.ID + "_" + propertyvalue.
>>>
>>> Thanks in advance,
>>>
>>> - DNJ
>>>
Brock Allen Guest
-
DotNetJunky #5
Re: UserControl inside of datagrid - loses its viewstate when datagrid is re-bound on postback
I call it directly on the DataGrid, not the Page... i have friends that
usually do the Page.DataBind() however i've never really used that method, i
try and control each (control) at the time it needs to be bound/manipulated,
plus i always check for rows before binding to list controls, and if there
are none i add a default/and or message.
The dropdownlist doesn't post back, it is just for selection only... no
selectedindexchanged event fires on it, no need for it.
I have been searching high and low for the answer but nothing has revealed
the problem... i am implementing INamingContainer on the usercontrol, so it
really isnt an ID conflict. the only thing i am definitely seeing during
debugging is that all the properties of the usercontrol on postback are
completely wiped from the ViewState. All properties read/write from
ViewState as i said using this.ID + "_" + as a prefix....
"Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
news:139748632470220914673056@msnews.microsoft.com ...> Ah, ok... hmm... Well, then when you rebind the DataGrid do you do it via
> the Page.DataBind() or do you do it directly on the DataGrid control? If
> you do it Page wide then you might be blasting the entries in the
> DropDownList.
>
> When you debug this, in your SelectedIndexChange event does the DDL have
> all of its items?
>
> -Brock
> DevelopMentor
> [url]http://staff.develop.com/ballen[/url]
>
>
>>>> Brock, The only time i am re-binding the datagrid is when
>> PageIndexChanged (requred for paging unless i am mistaken - IE, you
>> set the newpageindex and then call databind to show the new page) as
>> well as when rows are deleted or updated. Most importantly i need
>> this fixed for when rows are deleted...
>>
>> I am doing a check for page.ispostback on page_load and doing the
>> initial databind() there, however i also fire the databind() on the
>> events mentioned above.
>>
>> Thanks,
>> - DNJ
>> "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
>> news:128369632470051255114592@msnews.microsoft.com ...
>>>>> You should only load (DataBind) the DataGrid when IsPostBack is
>>> false. So don't do it in every request. Rebuilding it every time
>>> flushes the ViewState and thus all the behavior is going to not work
>>> as you've noticed.
>>>
>>> -Brock
>>> DevelopMentor
>>> [url]http://staff.develop.com/ballen[/url]
>>>> I have a simple usercontrol, a datepicker which contains 3
>>>> dropdownlist , it resides inside a datagrid column and i set the
>>>> selecteddate property of the usercontrol from one of the
>>>> DataBinder.Eval 's ... everythign works fine. The datepicker also
>>>> works fine on a regular page, and will normally persist its
>>>> viewstate on a page.postback event. However now i am trying to use
>>>> it in a datagrid and running into problems.
>>>>
>>>> When the datagrid is re-bound on postback or it's
>>>> selectedIndexChanged event, the usercontrol's dropdowns become
>>>> empty. It isnt saving it's viewstate and i cant figure out why.
>>>>
>>>> Can someone point me to the right direction of how to persist the
>>>> state of a usercontrol's dropdownlists on re-bind of the datagrid?
>>>>
>>>> Inside the usercontrol i am viewstating the properties of it, IE,
>>>> the selecteddate, selectedday/month/year , etc. Everything is
>>>> viewstated with a prefix of this.ID + "_" + propertyvalue.
>>>>
>>>> Thanks in advance,
>>>>
>>>> - DNJ
>>>>
>
>
DotNetJunky Guest
-
Brock Allen #6
Re: UserControl inside of datagrid - loses its viewstate when datagrid is re-bound on postback
> i have friends that usually do the Page.DataBind() however i've never really
usedWe all have "friends" that do *those* sorts of things ;)> that method
Well... we're still missing something. Sorry I can't tell what it is...> I have been searching high and low for the answer but nothing has
> revealed the problem... i am implementing INamingContainer on the
> usercontrol, so it really isnt an ID conflict. the only thing i am
> definitely seeing during debugging is that all the properties of the
> usercontrol on postback are completely wiped from the ViewState. All
> properties read/write from ViewState as i said using this.ID + "_" +
> as a prefix....
-Brock
DevelopMentor
[url]http://staff.develop.com/ballen[/url]
Brock Allen Guest
-
DotNetJunky #7
Re: UserControl inside of datagrid - loses its viewstate when datagrid is re-bound on postback
Sorry here is the ascx file as well, although just a few simple
dropdownlists.
Oops i guess there is some postback handling i forgot about... although just
for populating the year/month
I can catch that with a ItemCommand in the datagrid.. i just forgot about it
and apparently wasnt.
"Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
news:151037632470394763978704@msnews.microsoft.com ...> used>> i have friends that usually do the Page.DataBind() however i've never
>> really>>> that method
> We all have "friends" that do *those* sorts of things ;)
>>>> I have been searching high and low for the answer but nothing has
>> revealed the problem... i am implementing INamingContainer on the
>> usercontrol, so it really isnt an ID conflict. the only thing i am
>> definitely seeing during debugging is that all the properties of the
>> usercontrol on postback are completely wiped from the ViewState. All
>> properties read/write from ViewState as i said using this.ID + "_" +
>> as a prefix....
> Well... we're still missing something. Sorry I can't tell what it is...
>
> -Brock
> DevelopMentor
> [url]http://staff.develop.com/ballen[/url]
>
>
>
>
DotNetJunky Guest



Reply With Quote

