Bookcold

导航

GridView添加RadioButton列

 

aspx页面:

<asp:GridView ID="RadioGV" runat="server" AllowPaging="true" PageSize="5" OnRowDataBound="RadioGV_RowDataBound" > <Columns> <asp:TemplateField HeaderText="选择"> <ItemTemplate> <asp:Literal ID="RadioButtonMarkup" runat="server"></asp:Literal> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>  

cs页面:

protected void RadioGV_RowDataBound(object sender, GridViewRowEventArgs e) { if(e.Row.RowType == DataControlRowType.DataRow) { Literal output = e.Row.FindControl("RadioButtonMarkup") as Literal; output.Text = string.Format("<input type=\"radio\" name=\"ProductGroup\" " + "id=\"RowSelector{0}\" value=\"{0}\"" ,e.Row.RowIndex); } }   这样就可以添加onclick事件,判断selectchange() [...]

posted on 2010-01-25 22:00  bookcold  阅读(153)  评论(0)    收藏  举报