0
protected void Page_Load(object sender, EventArgs e)
    {
        Label2.Text = ListBox1.SelectedIndex.ToString();

    }

if label2.text is written in page load then its output is -1

protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Label2.Text = ListBox1.SelectedIndex.ToString();
    }

if i write label2.text in selected index change it returns nothing. please help me out.

1
  • 1
    The first case is normal as a value of -1 is returned if no item is selected... Commented Jul 3, 2012 at 8:48

1 Answer 1

1

Is autopostback set to true on the listbox?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.