Ask a Question related to ASP.NET Building Controls, Design and Development.
-
dave #1
Control missing property after postback with repeater
I am frustrated and not sure where to turn for help.
I have a custom control that has been working fine. The custom control is
composed of a dropdownlist and button. I have placed the control in a
repeater and it works just fine.
I have added a query filter at the top of the page where I create a new
datatable and rebind with the repeater. This is where the problem occcurs.
If I redirect to the page and execute the new query and rebind everything is
fine. If however, i postback the controls in the repeater do not seem to
have any properties and hence i get an error.
I would expect that this might be easy solution but i do not know what it
is.
I have implemented
Implements IPostBackDataHandler
Implements INamingContainer
One of the properties looks like the following (within the custom control)
Public Property DataTextField() As String
Get
If CType(ViewState("DataTextField"), Object) Is Nothing Then
Return _dataTextField
Else
Return CType(ViewState("DataTextField"), String)
End If
End Get
Set(ByVal value As String)
ViewState("DataTextField") = value
Me.DropDownList.DataTextField = value
_dataTextField = value
End Set
End Property
and also within the LoadPostData I do
Me.DataTextField = ViewState("DataTextField") and me.datatextfield has a
value after the postback.
The problem occurs when I try to rebind the same repeater with a new
datatable.
I do not understand how the postback would react differently than the page
load.
Any help would be very much appreciated.
thx
dave
dave Guest
-
UserControl with databound repeater drops values on postback
Hi all, I have a user control that contains a repeater that generates a list of check boxes. The checkboxes render fine, but they don't maintain... -
Control Not remembering property on postback
Hi, where in the lifecycle / events you reading/writing the value? Init, Load, postback event, PreRender...? -- Teemu Keiski ASP.NET MVP,... -
Newbie:Access custom Itemplate(not datagrid/repeater/datalist) control values on postback
Newbie:Access custom Itemplate(not datagrid/repeater/datalist) control values on postback Hi, I have simple Itemplate implementation with 2... -
Missing ID property for a custom control
Hello, When i'm using a custom control in my project, i can see that the custom control is missing it's ID in the HTML file. I can see the object... -
Composite control delegating databound templated features to child <asp:repeater> control
Hi Everybody, I'm creating a composite control in C# that basically renders a bunch of webcontrols such as <asp:Label />, <asp:Repeater />,... -
Gaurav Vaish \(www.EduJini.IN\) #2
Re: Control missing property after postback with repeater
> and also within the LoadPostData I do
Wrong approach. The PageLoad happens much after LoadPostData.> Me.DataTextField = ViewState("DataTextField") and me.datatextfield has a
> value after the postback.
> The problem occurs when I try to rebind the same repeater with a new
> datatable.
>
> I do not understand how the postback would react differently than the page
> load.
LoadPostData means that there is an 'input' element with the corresponding
ClientID in the form.
Also, it is not a good idea to implement INamingContainer and
IPostBackDataHandler simultaneously.
IPostBackDataHandler is meant for single elements.
INamingContainer is meant for multi-elements.
btw, can you elaborate what exactly you are trying to achieve. May be you
never need IPostBackDataHandler etc... which would be the case 99% of the
time.
--
Happy Hacking,
Gaurav Vaish | [url]http://www.mastergaurav.org[/url]
[url]http://www.edujini.in[/url] | [url]http://webservices.edujini.in[/url]
-------------------
Gaurav Vaish \(www.EduJini.IN\) Guest
-
Gaurav Vaish \(www.EduJini.IN\) #3
Re: Control missing property after postback with repeater
> IPostBackDataHandler is meant for single elements.
Or to be precise... HTML form elements.
--
Happy Hacking,
Gaurav Vaish | [url]http://www.mastergaurav.org[/url]
[url]http://www.edujini.in[/url] | [url]http://webservices.edujini.in[/url]
-------------------
Gaurav Vaish \(www.EduJini.IN\) Guest
-
dave #4
Re: Control missing property after postback with repeater
After the postback, i am able to get the old and current values of the
control (i.e. the value of the dropdown item selected). The problem occurs
when the page renders (after the postback) there is nothing selected in the
dropdown list and the values in the dropdown list are now empty.
i.e. the value of ViewState("DataTextField") or _dataTextField is now empty.
I was expecting that after the postback and render to the page that this
value would be retrieved for the population in the grid.
Remember, this control is located within a repeater which may be what is
complicating this situation.
After the postback, i do not rebind the repeater to the datasource (as I
would have expected that the values in the controls (custom) would have
remained in tact after the postback).
If necessary i can send or make available the source code of my control. I
really do need some help with this issue. THank you dave
dave Guest



Reply With Quote

