【发布时间】:2018-09-12 03:07:35
【问题描述】:
我有一个带有 asp:dropdownlist 的 GridView
我可以使用 rowdatabound 添加下拉值。
但是我需要做的是根据该行中另一个单元格的内容添加特定的下拉列表值。
例如,如果 Row(1) 和 Cell(2) = MAR001,我想要下拉值四、五和六
但是,如果 Row(1) 和 Cell(2) MAR001,我想要下拉值一、二和三。
这是我使用循环的尝试,但它没有正确定位下拉值。
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
非常感谢任何帮助。
【问题讨论】:
标签: asp.net vb.net drop-down-menu conditional