SPFieldChoice has a property named FieldRenderingControl
. Using reflector you can find this code in the FieldRedneringControl
property:
....
switch (this.EditFormat)
{
case SPChoiceFormatType.Dropdown:
control = new DropDownChoiceField();
break;
case SPChoiceFormatType.RadioButtons:
control = new RadioButtonChoiceField();
break;
default:
return null;
}
....
It seems that DropDownChoiceField
is our control. Navigate to this control and in CreateChildControls
you can see:
....
this.m_dropList.DataSource = this.DataSource;
this.m_dropList.DataValueField = "ValueField";
this.m_dropList.DataTextField = "TextField";
this.m_dropList.DataBind();
....
..lets go to DataSource
property:
....
DataTable table = new DataTable();
table.Locale = CultureInfo.InvariantCulture;
table.Columns.Add(new DataColumn("ValueField", typeof(string)));
table.Columns.Add(new DataColumn("TextField", typeof(string)));
if (string.IsNullOrEmpty((string) this.ItemFieldValue))
{
DataRow row = table.NewRow();
row[0] = string.Empty;
row[1] = string.Empty;
table.Rows.Add(row);
this.m_bHasBlankChoice = true;
}
for (int i = 0; i < base.NumberOfChoices; i++)
{
DataRow row2 = table.NewRow();
row2[0] = ((SPFieldChoice) base.Field).Choices[i];
row2[1] = row2[0];
table.Rows.Add(row2);
}
this.m_dataSource = new DataView(table);
}
return this.m_dataSource;
row2[1] = row2[0]
means that value attribute always equals to option's label and your experiments prove it (my answer is related to 2010 sharepoint)
If this behavior extremely needed, may be custom field type will be an option or any workarounds.