Skip to content

How can I store a hidden value with a combobox...

Basu Biswas

Asked Jan 29, 2007, 6:03 PM EST2 answers
Share
LinkedInX

Hi,

    Hi can I store some hidden value like primary key of an item with a combobox.

Like in ASP.NET the DropDownList has DataTextField and DataValueField for text and value.

I am adding item to ComboBox like this :
 
      cmbBrowseCombo.Items.Add("item1");
      cmbBrowseCombo.Items.Add("item2");

How can i add a hidden value to each Item....

If possible do reply...

thank you...

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hi,

    As you have also speciied DataTextField and DataValueFiled

    DataTextField is the value which we can see in a drop down.
    DataValueField is the value which stated the value that can be stored behind the drop down each item.

    You can bind the dataset with the dataSource like

    DropDown.DataSource=DataTable;
    Dropdown.DataTextField=DataTable["Primary_Key"];
    Dropdown.DataValueField=DataTable["Item_Value"];
    DropDown.DataBind();

    You can the each item value as well as the text later.
    0
  • 1 short reply
    • 0
      Thanks for the reply.......
      0