Databases Reference
In-Depth Information
LISTING 11.9 Continued
if (this.countryTemplate != null)
{
this.countryTemplate.AutoPostBack = true;
this.countryTemplate.DataBinding += this.CountryFieldValueChanged;
this.countryTemplate.FieldValueChanged += this.CountryFieldValueChanged;
}
}
protected override void ExtractValues(IOrderedDictionary dictionary)
{
dictionary[this.Column.Name] = this.ConvertEditedValue(this.textBox.Text);
}
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.OnFieldValueChanged(e);
}
private void CountryFieldValueChanged(object sender, EventArgs args)
{
this.Country = this.countryTemplate.FieldValueEditString;
}
}
}
The overridden OnLoad method passes the CountryField property value to the
FindOtherFieldTemplate method provided by the base class, FieldTemplateUserControl ,
to find the actual field template that was created for the Country property on the page. If
the country field template was found, its AutoPostBack property is set to true to make
sure that a post-back occurs when the user changes the country value and can update the
auto-completion list accordingly. The code also adds event handlers for the DataBinding
and FieldValueChanged events of the country template.
The DataBinding event fires during initial rendering of the page, when the initial values of
the country and region properties are loaded from the database. The FieldValueChanged
event fires during a post-back, when the user changes the country value on the page. In
both instances, you want to get the current value of the country field and use it to
provide a corresponding list of regions. As you recall from the discussion in Chapter 10,
the Region template uses the AutoCompleteExtender from the AJAX Control Toolkit to call
the RegionCompletionService method that provides the list of regions. The country value
serves as the contextKey in the web service call.
Search WWH ::




Custom Search