Databases Reference
In-Depth Information
LISTING 10.12 Continued
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication.DynamicData.FieldTemplates
{
public partial class StateEditField : FieldTemplateUserControl
{
public override Control DataControl
{
get { return this.dropDownList; }
}
private static readonly string[] states = new string[]
{
“AL”, “AK”, “AZ”, “AR”, “CA”, “CO”, “CT”, “DE”, “FL”, “GA”,
“HI”, “ID”, “IL”, “IN”, “IA”, “KS”, “KY”, “LA”, “ME”, “MD”,
“MA”, “MI”, “MN”, “MS”, “MO”, “MT”, “NE”, “NV”, “NH”, “NJ”,
“NM”, “NY”, “NC”, “ND”, “OH”, “OK”, “OR”, “PA”, “RI”, “SC”,
“SD”, “TN”, “TX”, “UT”, “VT”, “VA”, “WA”, “WV”, “WI”, “WY”
};
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
this.dropDownList.Items.Add(new ListItem(string.Empty));
foreach (string state in states)
this.dropDownList.Items.Add(new ListItem(state));
this.SetUpValidator(this.requiredFieldValidator);
this.SetUpValidator(this.dynamicValidator);
}
protected override void OnDataBinding(EventArgs e)
{
base.OnDataBinding(e);
if (this.dropDownList.Items.FindByValue(this.FieldValueEditString) != null)
this.dropDownList.SelectedValue = this.FieldValueEditString;
}
protected override void ExtractValues(IOrderedDictionary dictionary)
{
dictionary[this.Column.Name] =
this.ConvertEditedValue(this.dropDownList.SelectedValue);
Search WWH ::




Custom Search