【发布时间】:2015-03-13 19:39:10
【问题描述】:
我已经使用包含单选按钮列表和下拉列表的模板制作了一个 DataGrid。 更改单选按钮列表的索引时,下拉列表将填充值。我的 OnSelectedIndexChanged 方法代码是:
Protected Sub rbtnLstOptions_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim rbLst As RadioButtonList
Dim DBAccess As New DBAccess
Dim check As Integer
Dim strQuery As String
Dim ddl As String
Dim newval As String
For Each dgItem As DataGridItem In dgQuestions.Items
rbLst = CType(dgItem.FindControl("rbtnLstOptions"), RadioButtonList)
ddl = CType(dgItem.FindControl("ddlMembers"), DropDownList).SelectedValue
newval = CType(dgItem.FindControl("rbtnLstOptions"), RadioButtonList).SelectedValue
If (rbLst.SelectedValue.ToString <> "" And ddl = "") Or (rbLst.SelectedValue.ToString <> "" And rbLst.SelectedValue <> Me.PreviousSelectedValue) Then
check = rbLst.SelectedItem.Value
strQuery = "Select SNo,Participant from Participants where Role=" & check
dsRoles = DBAccess.RunQueryReturnDataset(strQuery)
CType(dgItem.FindControl("ddlMembers"), DropDownList).DataTextField = "Participant"
CType(dgItem.FindControl("ddlMembers"), DropDownList).DataValueField = "SNo"
CType(dgItem.FindControl("ddlMembers"), DropDownList).DataSource = dsRoles
CType(dgItem.FindControl("ddlMembers"), DropDownList).DataBind()
CType(dgItem.FindControl("ddlMembers"), DropDownList).Visible = True
'Me.PreviousSelectedValue = rbLst.SelectedValue
End If
Next
End Sub
运行此代码时,将遍历所有数据网格项,并根据给定的条件填充值。我希望仅在更改特定数据网格项目单选按钮索引而不是所有数据网格项目时才执行此方法。
【问题讨论】: