由于ASP.NET中的RadioButton控件在DataGrid 模板列中不能达到分组的效果,但是基于ASP.NET良好的编程性的前提下,要达到这个效果并不是很难.以前有见过一些朋友采用HTML控件可以达到这一效果,这里有我采用ASP.NET自带的RadioButton控件来编写的效果,虽然生成出来的JS不怎么漂亮,但也有一定的好处.
在ASPX页面中加入以下代码:
为DataGrid添加RadioButton按钮,实现单选效果<asp:datagrid class="grid" id="DataGrid1" runat="server" Width="720px" AllowSorting="True" AllowPaging="True"
为DataGrid添加RadioButton按钮,实现单选效果                                            PageSize
="3" AutoGenerateColumns="False" BackColor="White">
为DataGrid添加RadioButton按钮,实现单选效果                                            
<Columns>
为DataGrid添加RadioButton按钮,实现单选效果                                                
<asp:TemplateColumn>
为DataGrid添加RadioButton按钮,实现单选效果                                                    
<ItemTemplate>
为DataGrid添加RadioButton按钮,实现单选效果                                                        
<asp:RadioButton ID="radGroup" runat="server"></asp:RadioButton>
为DataGrid添加RadioButton按钮,实现单选效果                                                    
</ItemTemplate>
为DataGrid添加RadioButton按钮,实现单选效果                                                
</asp:TemplateColumn>
为DataGrid添加RadioButton按钮,实现单选效果                                                
<asp:BoundColumn DataField="CUSTNO" HeaderText="客户"></asp:BoundColumn>
为DataGrid添加RadioButton按钮,实现单选效果                                                
<asp:BoundColumn DataField="SBNO" HeaderText="单号"></asp:BoundColumn>
为DataGrid添加RadioButton按钮,实现单选效果                                                
<asp:BoundColumn DataField="ORDERNO" HeaderText="订单号码"></asp:BoundColumn>
为DataGrid添加RadioButton按钮,实现单选效果                                                
<asp:BoundColumn DataField="LOTNO" HeaderText="批号"></asp:BoundColumn>
为DataGrid添加RadioButton按钮,实现单选效果                                                
<asp:BoundColumn DataField="GETPCS" HeaderText="匹数">
为DataGrid添加RadioButton按钮,实现单选效果                                                    
<ItemStyle HorizontalAlign="Right"></ItemStyle>
为DataGrid添加RadioButton按钮,实现单选效果                                                
</asp:BoundColumn>
为DataGrid添加RadioButton按钮,实现单选效果                                                
<asp:BoundColumn DataField="GETKG" HeaderText="数量">
为DataGrid添加RadioButton按钮,实现单选效果                                                    
<ItemStyle HorizontalAlign="Right"></ItemStyle>
为DataGrid添加RadioButton按钮,实现单选效果                                                
</asp:BoundColumn>
为DataGrid添加RadioButton按钮,实现单选效果
为DataGrid添加RadioButton按钮,实现单选效果                        
</Columns>
为DataGrid添加RadioButton按钮,实现单选效果                                            
<PagerStyle Mode="NumericPages"></PagerStyle>
为DataGrid添加RadioButton按钮,实现单选效果                                        
</asp:datagrid>
在CS代码中加入以下代码段:
为DataGrid添加RadioButton按钮,实现单选效果private void DataGrid1_PreRender(object sender, System.EventArgs e)
        }

以上示例供学习ASP.NET的朋友参考.

相关文章: