I'm using VS2005 and am working with a ASP.NET 2.0 web site and I'm coding
in VB.NET.
I understand that I can add an item to a databound dropdownlist and make it
the default selection using the following code:
MyDropDownList.Items.Insert(0, "My default item")
MyDropDownList.SelectedIndex = 0
The problem that I am experiencing is *where* to put the above code! If I
place it in the Page_Load sub, the code is not applied, so I'm wondering
where I need to put the code in order for it to be applied after the
databinding has occured.
If, for example, I attach the code to a linkbutton, then it does exactly
what I expect, but understandably, I want the default option to be shown in
the dropdownlist when the page is first rendered.
I have played around with the various Page Events, but to no avail. If it's
any help, I'm using 'code behind'.
I'd very much appreciate any advice.
Thanks in advance,
IMB