Here's a programatic example:
<asp:TemplateColumn HeaderText myColumn ItemStyle-Wrap False >
<ItemTemplate>
<asp:DropDownList ID dropList1 Runat server DataTextField myText DataValueField table_identifier DataSource '< # GetSrc() >' SelectedIndex '< # GetSelIndex(Container.DataItem( myColumn )) >' Enabled '< # GetBool( myColumn ) >' OnSelectedIndexChanged GetSelChanged AutoPostBack True/>
</ItemTemplate>
Define this at the top of your code:
Dim ds As DataSet New DataSet
Function
GetSrc() As DataSetcnstr ConfigurationSettings.AppSettings( myDBConnString )
dropList1.Clear()
Dim cn As New SqlConnection(cnstr)sql SELECT table_identifier mytext FROM myTable
Dim da As SqlDataAdapterda
New SqlDataAdapter(sql cn)' fill dataset
cn.Open()
da.Fill(ds myTable )
cn.Close()' Add null row to dataset.
Dim dt As DataTable ds.Tables( myTable )Dim NullRow As DataRow dt.NewRow()
NullRow( table_identifier ) 0
NullRow( myText ) Select Something Here
dt.Rows.InsertAt(NullRow 0)Return dsEnd Function
Function
GetSelIndex(ByVal iVal As Object) As Integer' loop through datasetDim sVal As String iVal.ToString
Dim iLoop As Integer
Dim dt As DataTable
dt ds.Tables( myTable )For iLoop 0 To dt.Rows.Count - 1If sVal dt.Rows(iLoop)( table_identifier ).ToString Then Return iLoop
End IfNext iLoopEnd Function
Function GetBool()
' This function would contain code allowing you to disable the control if the user/entity did not have proper rights to use this control in the grid or change it.
End Function