【发布时间】:2016-02-17 07:14:07
【问题描述】:
我的任务是创建一个 Gridview,其中用户单击标题 (rblDifficulty) 上的单选按钮列表和下面行中的所有单选按钮列表 (rblDiff) 将被设置为相同的值。我已经使用复选框和 jquery 查看并修改了示例,但没有成功。希望有人可以指导我
<asp:GridView ID="gvData" runat="server" EmptyDataText="No Data" DataKeyNames="ID" AllowPaging="true" PageSize ="15"
class="" AutoGenerateColumns="False" OnPageIndexChanging="OnPaging">
<Columns>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:Label ID="lblName" runat="server" Text='<%# Eval("Name")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ID">
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Text='<%# Eval("ID")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Difficulty">
<HeaderTemplate>
<asp:RadioButtonList ID="rblDifficulty" runat="server">
<asp:ListItem Text="Easy" Value="0"></asp:ListItem>
<asp:ListItem Text="Medium" Value="Y"></asp:ListItem>
<asp:ListItem Text="Hard" Value="F"></asp:ListItem>
</asp:RadioButtonList>
</HeaderTemplate>
<ItemTemplate>
<asp:RadioButtonList ID="rblDiff" runat="server">
<asp:ListItem Text="Easy" Value="0"></asp:ListItem>
<asp:ListItem Text="Medium" Value="Y"></asp:ListItem>
<asp:ListItem Text="Hard" Value="F"></asp:ListItem>
</asp:RadioButtonList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
更新:jomsk1e 在这方面帮助了我
Protected Sub rblDifficulty_onChanged(sender As Object, e As EventArgs)
Dim rblDifficulty As RadioButtonList = DirectCast(gvData.HeaderRow.FindControl("rblDifficulty"), RadioButtonList)
Dim selectedValue__1 As String = rblDifficulty.SelectedValue
For Each row In gvData.Rows
Dim rbl As RadioButtonList = DirectCast(row.FindControl("rblDiff"), RadioButtonList)
rbl.SelectedValue = selectedValue__1
Next
End Sub
【问题讨论】:
-
因此,如果您在标题“Easy”中选择,Gridview-column 中的所有项目都应该设为 Easy 吗?这是你的需要吗?
-
是的,这就是我需要的......
标签: asp.net vb.net gridview radiobuttonlist