0

我有这样的简单网格视图

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataSourceID="SqlDataSource1">
        <Columns>
            <asp:TemplateField HeaderText="Status">
                <HeaderTemplate>
                    <asp:DropDownList ID="DropDownList1" runat="server">
                        <asp:ListItem>A</asp:ListItem>
                        <asp:ListItem>B</asp:ListItem>
                        <asp:ListItem>C</asp:ListItem>
                    </asp:DropDownList>
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:RadioButtonList ID="chkStatusGM" runat="server" AutoPostBack="false" RepeatDirection="Horizontal">
                        <asp:ListItem Value="5">Approve</asp:ListItem>
                        <asp:ListItem Value="0">Not Approved</asp:ListItem>
                    </asp:RadioButtonList>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="CATEGORY" HeaderText="CATEGORY"  />

        </Columns>
    </asp:GridView>

在网格视图中,单选按钮和列类别具有固定值,例如“A”,“B”,“C i 问题是我想根据从下拉列表中选择的值选择所有单选。例如,如果我选择“A " 从下拉菜单中,然后应选择具有 ctegory "A" 的 gridview 内的收音机,其值为 4。

4

1 回答 1

0

我自己找到了解决方案 这是代码

Protected Sub ddlupd(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim ddlupd As DropDownList = CType(GridView2.HeaderRow.FindControl("ddcat"), DropDownList)
        For Each gv As GridViewRow In GridView2.Rows
            Dim rdo As RadioButtonList = CType(GridView2.Rows(gv.RowIndex).FindControl("rblist"), RadioButtonList)
            Dim cat As Label = CType(GridView2.Rows(gv.RowIndex).FindControl("lblcat"), Label)
            If cat.Text = ddlupd.SelectedItem.Text Then
                rdo.SelectedValue = "4"
            ElseIf ddlupd.SelectedItem.Text = "Clear Selection" Then
                rdo.ClearSelection()
            ElseIf ddlupd.SelectedItem.Text = "Select All" Then
                rdo.SelectedValue = "4"
            End If
        Next
    End Sub
于 2013-08-20T04:29:23.560 回答