如何用一个Radio和一个LinkButton,实现RadioButton的功能
遇到了一个问题,在一个Repeater里面,有若干单选项,每次点击单选项都要进行一些操作。
本来想用RadioButton来做,但是RadioButton没有CommandName属性,而我这里必须要这样做:
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "update")
{
//……
}
}
所有我只有用了一个RadioButton和一个LinkButton,使得看起来像是一个RadioButton:
<asp:Repeater ID="Repeater1">
<ItemTemplate>
<asp:RadioButton ID="RadioButton1" runat="server" />
<asp:LinkButton ID="LinkButton1" CommandName="update" runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
但这里有几个不好实现的地方:
1. 如何在点击LinkButton的时候,相应的RadioButton为选中状态
2. 如何在选中RadioButton的时候,响应LinkButton的事件呢?
请哪位大侠给个完整的代码示例啊,或者用变通的方法解决我这个难题,万分感谢!