Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<asp:TemplateColumn HeaderText="Type">
<EditItemTemplate>
<asp:DropDownList id="ddType" runat="server">
<asp:ListItem>Chemistry</asp:ListItem>
<asp:ListItem>Bacteria</asp:ListItem>
<asp:ListItem>Stream</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Headertext="Zip-City">
<EditItemTemplate>
<asp:DropDownList id="ddZip"/>
</EditItemTemplate>
</asp:TemplateColumn>
..and in the codebehind..you can use a Function for binding...
Public Function PopulateZip() As DataView
'open database...
Dim dsZip As New System.Data.DataSet
daZip = New OleDbDataAdapter("SELECT Zip_Code, ZipCty FROM tblZipCodes", cnnZip)
daZip.Fill(dsZip)
return dsZip.Tables(0).DefaultView
End Function
...and in the Grid's ItemDataBound Event...
Sub Grid_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.EditItem Then
Dim itemType As ListItemType = e.Item.ItemType
If (itemType = ListItemType.EditItem) Then
'set Zip dropdown...
Dim ZipList As DropdownList = CType(e.Item.FindControl("ddZip"), DropDownList)
ZipList.DataTextField = "ZipCty"
ZipList.DataValueField = "Zip_Code"
ZipList.DataSource = PopulateZip()
ZipList.DataBind()
End If
End If
End Sub
..and finally add the ItemDataBound event to the <asp:DataGrid..> tag, q.v.,
OnItemDataBound="Grid_ItemDataBound"