【问题标题】:Access the value of dropdownlist in gridview edit mode, in DropDownList_SelectedIndexChanged event在 gridview 编辑模式下,在 DropDownList_SelectedIndexChanged 事件中访问下拉列表的值
【发布时间】:2013-03-15 15:19:00
【问题描述】:

我正在尝试在编辑模式下使用 Gridview 中的下拉列表执行回发。我在获取下拉列表的值时遇到问题。我不能在 RowDatabound 事件中这样做。

回发并没有超过写入行,我正在进入我想要执行一些操作的 DropDownList7_SelectedIndexChanged 事件,所以它甚至还没有到达那里。我确实在页面加载事件中有 If Postback。

  Protected Sub DropDownList7_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    Dim row As GridViewRow = DirectCast(GridView1.Rows.Item(0), GridViewRow)
    Dim newNumDDL As DropDownList = row.Cells(0).FindControl("DropDownList7")


    Dim newVal As Integer = newNumDDL.SelectedValue
    Dim newKey As String = newNumDDL.SelectedItem.ToString
    Dim newindex As Integer = newNumDDL.SelectedIndex

我认为问题是 findcontrol 我找不到 DDL,一直没有返回。

感谢您的帮助。

【问题讨论】:

    标签: asp.net vb.net gridview


    【解决方案1】:

    你不能用吗:

    Dim newNumDDL As DropDownList = DirectCast(sender, DropDownList)
    

    【讨论】:

      猜你喜欢
      • 2014-10-04
      • 2017-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多