Control missing property after postback with repeater

D

dave

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
 
D

dave

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top