Example Summary

Server side scripting with C#, Create a DataTable object w/data. Binding 'Text' and 'Value' fields in the dropdown box to specific columns of the DataTable. Trapping events using AutoPostBack & AutoEventWireup

This example demonstrates creating a DataTable object
in server side script and binding fields in the table to the dropdown box.
The dropdown box uses AutoPostBack="True" attribute in the tag to enable its events
The 'DataSource' property is set to the DataView object (implements ICollection)
The 'DataTextField' is set to a field name in the table ('ColorTextField')
The 'DataValueField' is set to a field name in the table ('ColorValueField')
// Page Language="C#" AutoEventWireup="true" <-- this goes up top
void Selection_Change(Object sender, EventArgs e) Add a handler in a script tag and your ready to go
The following is the code in the event hanlder that updates the textbox when the selection is changed
txtTask.Text = ColorList.Items[ColorList.SelectedIndex].Value;

DropDownList Data Binding Example

Open aspx test page