0

このようなドロップダウンの選択した値からラジオボタンを選択しようとしました

    Dim ddlupd As DropDownList = CType(grid.HeaderRow.FindControl("dropdown"), DropDownList)
        For Each gv As GridViewRow In grid.Rows
            Dim rdo As RadioButtonList = CType(grid.Rows(gv.RowIndex).FindControl("list"), RadioButtonList)
            Dim cat As Label = CType(grid.Rows(gv.RowIndex).FindControl("lblcat"), Label)
            If cat.Text = ddlupd.SelectedItem.Text Then
                rdo.SelectedValue = selflg.ToString()
            ElseIf ddlupd.SelectedItem.Text = "Clear Selection" Then
                rdo.ClearSelection()
            ElseIf ddlupd.SelectedItem.Text = "Select All" Then
                rdo.SelectedValue = selflg.ToString()
            End If
        Next

そして、このようにグリッドビューにテンプレートフィールドがあります

<asp:TemplateField HeaderText="Status">
     <HeaderTemplate>
         <asp:DropDownList ID="dropdown" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlupdGM1" BackColor="#3399FF" ForeColor="White">
             <asp:ListItem>Select Category</asp:ListItem>
             <asp:ListItem>Clear Selection</asp:ListItem>
             <asp:ListItem Value="1">Cane Payment</asp:ListItem>
             <asp:ListItem Value="2">Income Tax</asp:ListItem>
             <asp:ListItem Value="3">Fund Transfer</asp:ListItem>
             <asp:ListItem Value="4">Others</asp:ListItem>
         </asp:DropDownList>
     </HeaderTemplate>
     <ItemTemplate>
         <asp:RadioButtonList ID="chkStatusGM" runat="server" AutoPostBack="false" RepeatDirection="Horizontal" OnSelectedIndexChanged="chkStatus_OnCheckedChangedGM">
             <asp:ListItem Value="5">Approve</asp:ListItem>
             <asp:ListItem Value="0">Not Approved</asp:ListItem>
         </asp:RadioButtonList>
     </ItemTemplate>
 </asp:TemplateField>

また、ラジオ ボタンの値を選択して、データベースに対して更新コマンドを実行しています。更新は正常に機能します。

更新 **

Protected Sub chkStatus_OnCheckedChangedGM(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim cmd As OleDbCommand = New OleDbCommand()

        Dim chkStatusGM As RadioButtonList = CType(sender, RadioButtonList)
        Dim row As GridViewRow = CType(chkStatusGM.NamingContainer, GridViewRow)
        Dim bpvnum As String = row.Cells(4).Text

        cmd.CommandText = "update sml.FND_01_11@wbg set sta_flg=:sta_flg where bpv_num=:bpv_num and bpv_dte=:bpv_dte"
        cmd.CommandType = CommandType.Text
        cmd.Connection = con

        cmd.Parameters.Add(":sta_flg", OleDbType.BigInt).Value = chkStatusGM.SelectedValue
        cmd.Parameters.Add(":bpv_num", OleDbType.BigInt).Value = bpvnum
        cmd.Parameters.Add(":bpv_dte", OleDbType.Date).Value = TreeView2.SelectedValue
        Try
            con.Open()
            cmd.ExecuteNonQuery()
            con.Close()
        Catch ex As Exception
            Response.Write(ex.ToString())
        End Try
    End Sub

**

4

1 に答える 1