如何在Asp.Net中访问网格视图的已检查单选按钮的值

时间:2017-07-31 13:05:21

标签: c# asp.net

这是网格视图的代码,当我点击率按钮时,我想访问代码中所选单选按钮的值。

以下是我的代码:

<asp:DataGrid ID="Grid" runat="server" PageSize="5" AllowPaging="True" DataKeyField="vmId"
              AutoGenerateColumns="False" CellPadding="10" ForeColor="#CC3300"  GridLines="None" AlternatingItemStyle-CssClass="table" BorderColor="#000066" OnItemCommand="Grid_ItemCommand" OnSelectedIndexChanged="Grid_SelectedIndexChanged" CaptionAlign="Bottom" CellSpacing="5" BackColor="#666699">
    <Columns>
        <asp:BoundColumn HeaderText="Venue Id" DataField="vmId" HeaderStyle-BackColor="#CCCCCC" HeaderStyle-ForeColor="Black"  HeaderStyle-BorderColor="#999999" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1" ItemStyle-BorderColor="#999999" ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1"></asp:BoundColumn>
        <asp:BoundColumn HeaderText="Venue Name" DataField="vName" HeaderStyle-BackColor="#CCCCCC" HeaderStyle-ForeColor="Black" HeaderStyle-BorderColor="#999999" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1" ItemStyle-BorderColor="#999999" ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1"></asp:BoundColumn>

        <asp:TemplateColumn HeaderText="Rate Venue" HeaderStyle-BackColor="#CCCCCC" HeaderStyle-ForeColor="Black" HeaderStyle-BorderColor="#999999" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1" ItemStyle-BorderColor="#999999" ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1">
            <ItemTemplate>
                <asp:RadioButton ID="rbt1" runat="server" GroupName="rate" Text="1" />

                <asp:RadioButton ID="rbt2" runat="server" GroupName="rate" Text="2" />
                <asp:RadioButton ID="rbt3" runat="server" GroupName="rate" Text="3" />
                <asp:RadioButton ID="rbt4" runat="server" GroupName="rate" Text="4" />
                <asp:RadioButton ID="rbt5" runat="server" GroupName="rate" Text="5" />

                <asp:Button ID="btnRate" runat="server" Text="Rate" OnClick="btnRate" Style="text-align: center; margin: 5px 0 0 0;" />
            </ItemTemplate>
        </asp:TemplateColumn>
        <asp:ButtonColumn CommandName="ViewDetails" HeaderText="Action" Text="Details" HeaderStyle-BackColor="#CCCCCC" HeaderStyle-ForeColor="Black" HeaderStyle-BorderColor="#999999" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1" ItemStyle-BorderColor="#999999" ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1"></asp:ButtonColumn>
        <asp:ButtonColumn CommandName="reserveVenue" HeaderText="Reserve Venue" Text="Reserve Venue" HeaderStyle-BackColor="#CCCCCC" HeaderStyle-ForeColor="Black" HeaderStyle-BorderColor="#999999" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1" ItemStyle-BorderColor="#999999" ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1"></asp:ButtonColumn>
    </Columns>
    <FooterStyle BackColor="#CCCCCC" Font-Bold="True" ForeColor="White" />
    <SelectedItemStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
    <PagerStyle BackColor="#CCCCCC" ForeColor="#333333" HorizontalAlign="Center" Mode="NumericPages" />
    <ItemStyle BackColor="White" ForeColor="#333333" BorderStyle="Solid" BorderColor="#999999" BorderWidth="1" />
    <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
</asp:DataGrid>

0 个答案:

没有答案