gridview中列中的不同下拉列表

时间:2015-08-22 10:55:06

标签: asp.net gridview

我有一个gridview,其中有一个包含dropdownlist的列。我不能为每一行提供不同的dropdownlist项,每行dropdownlist的项目是相同的。我希望我的第一行dropdownlist具有例如{1,2,3}的项目,第二行的{2,3,5,7}等等。我不想拥有相同的内容每行dropdownlist但我不知道如何做到这一点。 提前谢谢

Protected Sub GridView2_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GridView2.RowDataBound
    If (e.Row.RowType = DataControlRowType.DataRow) Then
        Dim list_color As DropDownList = CType(e.Row.FindControl("colorList"), DropDownList)
        Dim dt3 As New DataTable
            Dim adapter As New OleDbDataAdapter("SELECT ID, name FROM color WHERE ID IN (" & GridView2.Rows(index).Cells(10).Text.ToString & ")", conn)
            adapter.Fill(dt3)
            list_color.DataSource = dt3
            list_color.DataTextField = "name"
            list_color.DataValueField = "name"
            list_color.DataBind()
    End If
End Sub

0 个答案:

没有答案