Drop Down List Selected Index!!!

Discussion in 'ASP .Net' started by Anthony Judd, Nov 1, 2004.

  1. Anthony Judd

    Anthony Judd Guest

    When I user click a link buttton i am calling a stored procedure and
    provided the required parameters.
    Unfortunately it seeems I can't seem to get the right selectedItem when the
    page posts.
    Any insight into getting around this is appreciated!!!

    void new_menu_Click(object sender, EventArgs e) {
    String dsn = "Initial Catalog=cms;Data Source=localhost;Integrated
    Security=SSPI";
    SqlConnection MyConnection = new SqlConnection(dsn);
    MyConnection.Open();
    SqlCommand cmd = new SqlCommand("add_menu",MyConnection);

    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add("@menu_name", SqlDbType.VarChar, 40).Value =
    menu_name.Text;
    cmd.Parameters.Add("@menu_parent", SqlDbType.Int, 4).Value =
    menu_parent.SelectedItem.Value;
    //always evaluates to first element despite selecting a different item.

    cmd.Parameters.Add("@page_id", SqlDbType.Int, 4).Value =
    page_id.SelectedItem.Value;
    cmd.ExecuteNonQuery();
    }
    Anthony Judd, Nov 1, 2004
    #1
    1. Advertising

  2. Hi,
    The problems seems to be with postback. Check if you are rebinding the
    dropdownlist on postback also.

    HTH
    srini

    "Anthony Judd" wrote:

    > When I user click a link buttton i am calling a stored procedure and
    > provided the required parameters.
    =?Utf-8?B?c3Jpbmk=?=, Nov 1, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J. Babe

    Drop down list selected index

    J. Babe, Aug 5, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    9,519
    Steve C. Orr, MCSD
    Aug 5, 2003
  2. Replies:
    0
    Views:
    4,856
  3. DCC700
    Replies:
    0
    Views:
    935
    DCC700
    Jul 14, 2006
  4. weiwei
    Replies:
    0
    Views:
    1,002
    weiwei
    Jan 5, 2007
  5. Replies:
    0
    Views:
    163
Loading...

Share This Page