Datalist adding Dynamic controls

I have a Datalist, that I fill with the PopulateList() method. This method
selects all Items from Database and binds the Dataset to the DataLilst. Now,
when clicking Edit, in the Editcommand I add some dynamic TextBoxes to a
PlaceHolder in the EditItemTemplate.

So fare, all fine - now, when I select Update, in the UpdateCommand-Event I
want to get the Value of these added TextBoxes. My Problem is now, when I
just search for the PlaceHolder and check all controls inside, it is empty.
So I run the PopulatePlaceHolder method also in the UpdateCommand and i find
the controls, but they don't have any values inside.

Advertisements

"Patrick" <> wrote in message
news:%...
> Hello
>
> I have a Datalist, that I fill with the PopulateList() method. This method
> selects all Items from Database and binds the Dataset to the DataLilst.
Now,
> when clicking Edit, in the Editcommand I add some dynamic TextBoxes to a
> PlaceHolder in the EditItemTemplate.
>
> So fare, all fine - now, when I select Update, in the UpdateCommand-Event
I
> want to get the Value of these added TextBoxes. My Problem is now, when I
> just search for the PlaceHolder and check all controls inside, it is
empty.
> So I run the PopulatePlaceHolder method also in the UpdateCommand and i
find
> the controls, but they don't have any values inside.

You need to run the PopulatePlaceHolder method in Page_Init instead,
so that the controls are already in place when they are filled with their
viewstate information (this happens after Page_Init and before Page_Load).

Advertisements

Hi Jos
> You need to run the PopulatePlaceHolder method in Page_Init instead,
> so that the controls are already in place when they are filled with their
> viewstate information (this happens after Page_Init and before Page_Load).

Thanks for your answer. This is a good Idea, but the problem is, I add this
TextBoxes to the EditItemTemplate, so on the PageInit there is nothing in
Edit, so it won't add anything. And afterwards, when I edit something, that
code won't be executed.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!