You must Sign In to post a response.
  • Category: .NET

    How to set a default value for a Combo Box?

    How to set a default value for a Combo Box in c#.net?

    i have the following items:

    --select--
    1
    2
    3
    4
    5
    6

    here i want to set the default value as --select--

    cam anyone give the solution?

    Thanks & Regards,
    Vidhya
  • #285592
    hi
    pl try
    ddlInChargeName.Items.Insert(0, New ListItem("", "-1"))
    ddlInChargeName.SelectedIndex = ddlInChargeName.Items.IndexOf(ddlInChargeName.Items.FindByValue("-1"))

  • #285596
    After you populate all values into the list, you can add this at the end

    ddlList.Items.Insert(0, new ListItem("Select","Select"));
    ddlList.SelectedIndex = -1;

  • #285597
    hi,

    thanks Mr.vengatesan.

    using ur code i got some information..

    i got the solution also.

    use this code to set default value:
    comboBox1.SelectedIndex=day_comboBox.Items.IndexOf("--Select--");

    Thanks & Regards,
    Vidhya

  • #285828
    Hi,


    Using selectedindex propery we can do this.

    Dropdownbox.selectedindex=-1

    Regards
    JK

    Thanks & Regards
    D.Jeya Kumar(JK)


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.