So I managed to figure this one out on my own actually. You can simply modify code for one of the existing Field Templates to do what I'm looking to do.
As stated, the idea is to take a text box for data entry on the Insert page and turn it into a dropdown list of values, where that dropdown is comprised of data from another table. The user would then select the value needed, and it would be passed back to the database as part of the insert process.
Start by creating a new control in the FieldTemplates folder. Name it something like DropDown. You'll have your ascx, the code behind file, and the designer file.
Then, take the code from the ascx file for Enumeration_Edit, and copy it into the ascx file for your new dropdown control. You may need to rename the ID of the DropDownList control.
With the code behind, copy the code from the Enumeration_Edit control's code behind and alter them to meet the needs of the dropdown.
Your PageLoad class should look like this:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
OnDataBinding();
}
SetUpValidator(RequiredFieldValidator1);
SetUpValidator(DynamicValidator1);
}
Your OnDataBinding should be setup like this:
public void OnDataBinding()
{
//Code for binding data from a query/stored proc to a dropdown should go here.
}
Keep the ExtractValues() and DataControl() classes, but you can get rid of the EnumType() class.
Also be sure to add any references you may need. Compare the code behind for the Enumeration_Edit control and your new control to figure this out.
Now, to make the control work on the text box for the column you want it to control data insertion for. You can simply add a [UIHint("DropDown")]
to the appropriate column item for your partial class for the table, but that will apply the control to all instances of that column when displayed. I have custom pages setup for each of my tables, and I only want this control used for the insert functionality of a specific column. As such, I altered my Insert page for this table to make the line controlling this column to look like this:
<asp:DynamicField DataField="COLUMN_NAME" UIHint="DropDown" ReadOnly="true" />
Doing it this way you only apply the control to this column on this page. You need to set the ReadOnly value to true, otherwise it will still render as a text input field and not a dropdown.
From there, your insert page should have a dropdown for data entry on that column.
I only needed it for this one column, so the code for tying the data to my dropdown is only setup to work for this one column. You may be able to write a query that looks up all values for a particular column based on the column you've tied the control to, or you may simply need to create your own Field Templates for each column you need to have a dropdown list for.