我有一个带有asp:dropdownlist的GridView
我可以使用rowdatabound添加下拉列表值。
然而,我需要做的是根据该行中另一个单元格的内容添加特定的下拉列表值。
例如,如果行(1)和单元格(2)=MAR001,我想要下拉值4、5和6
但是,如果行(1)和单元格(2)<&燃气轮机;MAR001,我想要下拉值1、2和3。
下面是我使用循环的尝试,但是它没有正确地针对下拉列表值。
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
For i As Integer = 0 To GridView1.Rows.Count - 1
Dim Name As String = GridView1.Rows(i).Cells(2).Text
If Name = "MAR001" Then
Dim ddl As DropDownList = e.Row.FindControl("ddlQuantity")
Dim numbers As New List(Of String)()
numbers.Add("Four")
numbers.Add("Five ")
numbers.Add("Six")
ddl.DataSource = numbers
ddl.DataBind()
Else
Dim ddl As DropDownList = e.Row.FindControl("ddlQuantity")
Dim numbers As New List(Of String)()
numbers.Add("One")
numbers.Add("Two")
numbers.Add("Three")
ddl.DataSource = numbers
ddl.DataBind()
End If
Next
Else
End If
End Sub
非常感谢您的帮助。