Selectedindexchanged on page load

  • Thread starter Thread starter Morten
  • Start date Start date
M

Morten

Hi!

I have a form containing a listbox control. The control is configured to
autopostback. When I manually select a new item in the list I'm getting
properties for the selected item displayed in various textboxes and labels.
My problem is that I'd like to automatically display the properties for the
first item in the list when the page loads. I've put this in the Page_Load
part of the form:

if(!IsPostBack)
{

ListBox_all_users.SelectedIndex = 0;

}

This has caused the first item to be selected but the properties are not
fetched so it appears that the SelectedIndexChanged event isn't fired. Can I
make this happen somehow?

Thanks for your help

Morten
 
Hello Morten,

Why not subtract the code you have in your OnSelectedIndexChanged() to a
new private method,
have OnSelectedIndexChanged() refer to that new method, and place a call
to your new method right after
ListBox_all_users.SelectedIndex = 0;

HTH
Christiaan
 
Back
Top