locked
How to set Picklist value in code RRS feed

  • Question

  • Method 1:

    myCon.address1_addresstypecode = ddlAddressType.SelectedItem.Value.ToString();
    Error:  Cannot implicitly convert type 'string' to 'Picklist'

    Method 2:

     

    string address = ddlAddressType.SelectedItem.Value.ToString(); 

    Error:  Cannot implicitly convert type 'string' to 'Picklist'

    if i use the above methods am getting the error message which i marked in yellow color.

    how to insert the value for Picklist from C# to SQL SERVER 2005.

    Guid addr = new Guid(address); 
    Picklist pl = new Picklist();
    pl.Value =
    Convert.ToInt16(addr);
    pl.name =
    EntityName.contact.ToString();
    myCon.address1_addresstypecode = address;

     

    Saturday, March 28, 2009 6:55 AM

Answers

  • Picklist

    plist_addr = new Picklist();

    plist_addr.name = ddlAddressType.SelectedItem.Text.ToString();

    plist_addr.Value =

    int.Parse(ddlAddressType.SelectedValue.ToString());

     

    PicklistProperty addr_code = new PicklistProperty();

    addr_code.Name =

    "address1_addresstypecode";

    addr_code.Value = plist_addr;

    Saturday, March 28, 2009 8:50 AM