Oops! The Dim statement must go outside the Page_Load method for the sl object to be visible to the rest of the page.
>Vic,
>
>Enums are really for design-time convenience only. To do what you are talking about requires that you put the text and key values into an array or SortedList. Arrays have less overhead, but a SortedList might be better because it specifically uses a Key/Value pair.
>
>First, load the SortedList with data in the Page_Load method:
>
>Dim sl As New SortedList()
>
>sl.Add(1, "Custom Software")
>sl.Add(2, "Consulting Services")
>sl.Add(3, "Hardware")
>
>
>Then you can bind the grid's column to CStr(sl.Item(iDepartment)).
>
>If you want to use a DropDownList in the EditItem template, set the DataSource of the DropDownList control to "sl" (without the quotes), the DataTextField to "Value" (no quotes again) and the DataValueField to "Key" (no quotes).
>
>To bind that DropDownList to a DataSet, bind the SelectedIndex property to the following:
>
>sl.IndexOfKey(DataBinder.Eval(Container, "DataItem.iDepartment"))
>
>
>>How does one use an enum (that I created) to display the text value in the web datagrid for the numerical value stored in the database?
>>
>>What I mean is that the iDepartment field for a particular row in the table has a value of 1 (this equals customsoftware) and I have an enum created for Departments where customsoftware = 1. How do I get the word customsoftware to display in the grid instead of the number 1?
>>
>>Thanks,
>>
>>Vic