数据结构:
表dep:depid(标识主键),depname(学院名字)
表stu:stuid(标识主键),stuname(学生名字),studepid(depid字段内容)
<%@ Page Language="VB" AutoEventWireup="True" Debug="true"%>

<%@ Import Namespace =Namespace="System.Data" %>

<%@ Import Namespace =Namespace="System.Data.SQLClient" %>
<script runat="server">
Dim strDropDownListValue as String
Dim MyConnection as SQLConnection = New SqlConnection("server=localhost;Initial Catalog=nhlinkin;uid=sa;pwd=")
Dim MyCommand As SQLDataAdapter

Sub Page_Load()Sub Page_Load(sender As Object, e As EventArgs)
If Not IsPostBack Then
BindGrid()
End If
End Sub

Sub BindGrid()Sub BindGrid()
Dim MyCommand As SQLDataAdapter = new SQLDataAdapter("SELECT * FROM stu,dep WHERE stu.studepid=dep.depid", MyConnection)
Dim DS As DataSet = new DataSet()
MyCommand.Fill(DS,"min")
MyDataGrid.DataSource = DS.Tables("min").DefaultView
MyDataGrid.DataBind()
End Sub

Sub MyDataGrid_Paging()Sub MyDataGrid_Paging(sender as Object, e As DataGridPageChangedEventArgs)
MyDataGrid.CurrentPageIndex = e.NewPageIndex
BindGrid()
End Sub

Sub MyDataGrid_Edit()Sub MyDataGrid_Edit(Sender As Object, E As DataGridCommandEventArgs)
Response.Write(e.Item.Cells(0).Text)
MyDataGrid.EditItemIndex = CInt(E.Item.ItemIndex)
strDropDownListValue = Ucase(CType(e.Item.FindControl("lblDepName"), Label).Text)
BindGrid()
Response.Write(strDropDownListValue)
End Sub

Sub MyDataGrid_Cancel()Sub MyDataGrid_Cancel(sender As Object, e As DataGridCommandEventArgs)
MyDataGrid.EditItemIndex = -1
BindGrid()
End Sub

Sub MyDataGrid_Delete()Sub MyDataGrid_Delete(sender As Object, e As DataGridCommandEventArgs)
MyDataGrid.EditItemIndex = -1
BindGrid()
Response.Write(e.Item.Cells(0).Text)
End Sub

Sub MyDataGrid_ItemDataBound()Sub MyDataGrid_ItemDataBound(s as object, e as DataGridItemEventArgs)
If e.item.itemType = ListItemType.EditItem Then
Dim myDropDown as DropDownList
myDropDown = Ctype(e.Item.FindControl("dropDepName"), DropDownList)
myDropDown.SelectedIndex =myDropDown.Items.IndexOf(myDropDown.items.findbytext(strDropDownListValue))
End If
End Sub

Private Function BindDropDownList()Function BindDropDownList()
Dim myCommand As sqlCommand = New sqlCommand("SELECT * FROM dep ORDER BY depID ASC", myConnection)
myConnection.Open()
Return myCommand.ExecuteReader(CommandBehavior.CloseConnection)
End Function
</script>
<form runat="server">
<asp:DataGrid id="MyDataGrid"
runat="server"
AutoGenerateColumns="False"
Width="200"
AllowPaging="True"
PageSize="5"
OnPageIndexChanged="MyDataGrid_Paging"
OnEditCommand="MyDataGrid_Edit"
OnCancelCommand="MyDataGrid_Cancel"
OnDeleteCommand="MyDataGrid_Delete"
OnItemDataBound="MyDataGrid_ItemDataBound"
>
<HeaderStyle BackColor="Navy"
ForeColor="White"
Font-Bold="True"
HorizontalAlign="Center"/>
<PagerStyle Mode="NextPrev"
HorizontalAlign="Right"
NextPageText="Next"
PrevPageText="Prev"/>
<Columns>
<asp:BoundColumn DataField="stuid" HeaderText="StuID" ReadOnly="true"/>
<asp:BoundColumn DataField="stuname" HeaderText="stuname"/>
<asp:TemplateColumn HeaderText="StuDepID">
<ItemTemplate>
<asp:Label ID="lblDepName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "DepName") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList id="dropDepName" DataSource="<%# BindDropDownList()%>" DataTextField="depName" DataTextValue="depID" runat="server" />
</EditItemTemplate>
</asp:TemplateColumn>
<asp:EditCommandColumn
ButtonType="PushButton" UpdateText="Update" CancelText="Cancel"
EditText="Edit" HeaderText="Edit">
</asp:EditCommandColumn>
<asp:TemplateColumn HeaderText="Delete">
<ItemTemplate>
<asp:Button CommandName="Delete" Text="Delete" ID="btnDel" Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</form>