Selectedindexchanged on page load

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
 
C

Chris van Bergen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top