troubleshooting Question

Datalist Dynamic Controls - ItemDataBound

Avatar of JamesAStewart
JamesAStewart asked on
Web Languages and Standards.NET ProgrammingASP.NETVisual Basic.NET
4 Comments1 Solution723 ViewsLast Modified:
I am trying to write a messaging system which will allow people to communicate and write messages to each other.

I have a datalist which is populated by an ObjectDataSource. On the ItemDataBound event of the datalist I pick out the data which I want to display and show it in a selection of labels and textboxes .etc... This part of my system works okay.

What I am now trying to do is as follows. We want to allow users to reply to messages and then display them under the message they have replied to. Again, this part of the system works ok, but i now want to add buttons into the replies to allow users to delete .etc... The replies are populated dynamically on the ItemDataBound event, so that we can check whether there are any replies to the each of the messages in the datalist, it has to be done on this event.

After I have dynamically added the buttons in the ItemDataBound event they display on screen fine but when i click the button all of the replies dissapear. I am led to believe that this is because the page is doing a postback and therefore the replies are lost because they are dynamically created. When the button is clicked, I ideally want to call an event in the code behind, using the 'Add Handler' method.

Does anyone have any ideas how I might be able to get this working, or if it seems possible to get it to work?

Many Thanks in Advance.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros