Drop Down list null value not working for selected text c#?

Posted by Tamara JQ on Stack Overflow See other posts from Stack Overflow or by Tamara JQ
Published on 2010-04-22T13:18:58Z Indexed on 2010/04/22 13:23 UTC
Read the original article Hit count: 611

Filed under:
|
|
|
|

Hi guys,

Basically I have a drop down list which is populated with text and values depending on a selected index of a radio button list. The code is as follows:

protected void RBLGender_SelectedIndexChanged(object sender, EventArgs e)
    {
        DDLTrous.Items.Clear();
        DDLShoes.Items.Clear();
        if (RBLGender.SelectedValue.Equals("Male"))
        {

            String[] MaleTrouserText = {"[N/A]", "28\"", "30\"", "32\"", "34\"", "36\"", "38\"", "40\"", "42\"", "44\"", "48\""};
            String[] MaleTrouserValue = { null, "28\"", "30\"", "32\"", "34\"", "36\"", "38\"", "40\"", "42\"", "44\"", "48\"" };
            String[] MaleShoeText = { "[N/A]", "38M", "39M", "40M", "41M", "42M", "43M", "44M", "45M", "46M", "47M" };
            String[] MaleShoeValue = { null, "38M", "39M", "40M", "41M", "42M", "43M", "44M", "45M", "46M", "47M" };
            for (int i = 0; i < MaleTrouserText.Length; i++)
            {
                ListItem MaleList = new ListItem(MaleTrouserText[i], MaleTrouserValue[i]);
                DDLTrous.Items.Add(MaleList);

            }
            for (int i = 0; i < MaleShoeText.Length; i++)
            {
                ListItem MaleShoeList = new ListItem(MaleShoeText[i], MaleShoeValue[i]);
                DDLShoes.Items.Add(MaleShoeList);

            }

        }

            else if (RBLGender.SelectedValue.Equals("Female"))`

When the text '[N/A]' is selected I want the value NULL to be inserted into the database. At present when '[N/A]' is selected the value entered into the database is [N/A] does anyone know why?

Thanks in advance.

© Stack Overflow or respective owner

Related posts about c#

Related posts about dropdownlist