TreeView Adapter SelectedValue problem RRS feed

  • Question

  • User-782782594 posted

    I am having a problem using the SelectedValue proprty outside of the onClick event. I have added the following code to SimpleTreeView.aspx in the walk through example code. When using the adapter, EntertainmentTreeView.SelectedValue is always null. When not using the adapter, EntertainmentTreeView.SelectedValue contains the expected value for the item I clicked.

    Why can I not access EntertainmentTreeView.SelectedValue outside of the OnClick method?

    Here's the code I added (just putting the onclick guts into Page_Load):

    protected void Page_Load(object sender, EventArgs e)
    MessageLabel.Text = "You selected " + EntertainmentTreeView.SelectedValue + ".";

    Wednesday, June 27, 2007 4:42 PM

All replies

  • User-534056067 posted

    Embarassingly, this is a known problem, http://forums.asp.net/t/1049311.aspx. I offered a possible workaround, ableit kludgy, which is to do more of your work in Page_PreRender rather than Page_Load. However, as others on that thread note, this is hardly an elegant or perfect solution. Still, it's the best I could think of now. Remember, the adapters are now maintained by the community at CodePlex. So, if you come up with a great solution (read: fix for my bug) you might want to ask to be added to the CodePlex project as a contributing developer.

    Hope this helps at least get you started...

    Wednesday, June 27, 2007 8:35 PM