|
using System;
using System.Collections.Specialized;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace BasicDataViewer.DynamicData.FieldTemplates
{
public partial class ForeignKey_EditField : System.Web.DynamicData.FieldTemplateUserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (DropDownList1.Items.Count == 0)
{
if (Mode == DataBoundControlMode.Insert || !Column.IsRequired)
{
DropDownList1.Items.Add(new ListItem("[Not Set]", ""));
}
PopulateListControl(DropDownList1);
}
SetUpValidator(RequiredFieldValidator1);
SetUpValidator(DynamicValidator1);
}
protected override void OnDataBinding(EventArgs e)
{
base.OnDataBinding(e);
string selectedValueString = GetSelectedValueString();
ListItem item = DropDownList1.Items.FindByValue(selectedValueString);
if (item != null)
{
DropDownList1.SelectedValue = selectedValueString;
}
}
protected override void ExtractValues(IOrderedDictionary dictionary)
{
// If it's an empty string, change it to null
string value = DropDownList1.SelectedValue;
if (String.IsNullOrEmpty(value))
{
value = null;
}
ExtractForeignKey(dictionary, value);
}
public override Control DataControl
{
get
{
return DropDownList1;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.