• GridView中的Radio


    1.html
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        
    <title>GridView中的Radio</title>
    </head>
    <body>
        
    <form id="form1" runat="server">
            
    <div>
                
    <asp:GridView ID="GridView1" Width="100%" runat="server" AutoGenerateColumns="false">
                    
    <Columns>
                        
    <asp:TemplateField>
                            
    <HeaderTemplate>
                                单选
    </HeaderTemplate>
                            
    <ItemTemplate>
                                
    <input type="radio" id="RadioName" name="RadioName" value='<%# Eval("au_id")%>'/>
                            
    </ItemTemplate>
                        
    </asp:TemplateField>
                        
    <%--<asp:BoundField DataField="au_id" HeaderText="au_id" />--%>
                        
    <asp:BoundField DataField="au_lname" HeaderText="au_lname" />
                        
    <asp:BoundField DataField="au_fname" HeaderText="au_fname" />
                        
    <asp:BoundField DataField="phone" HeaderText="phone" />
                        
    <asp:BoundField DataField="address" HeaderText="address" />
                    
    </Columns>
                
    </asp:GridView>
                
    <asp:Button ID="Button1" runat="server" Text="显示" OnClick="Button1_Click" /></div>
        
    </form>
    </body>
    </html>
    2.cs
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    public partial class GridView_GridView_Radio : System.Web.UI.Page
    {
        Practice.DAL.authors authorsbll 
    = new Practice.DAL.authors();

        
    protected void Page_Load(object sender, EventArgs e)
        
    {
            
    if (!IsPostBack)
            
    {
                DataBindGridView();
            }

        }


        
    /// <summary>
        
    /// 功    能:绑定GridView
        
    /// 作  者:PUKE
        
    /// 完成时间:2007-05-18
        
    /// 版  权:pukesys@tom.com
        
    /// </summary>

        private void DataBindGridView()
        
    {
            DataSet ds 
    = authorsbll.GetList("");
            GridView1.DataSource 
    = ds;
            GridView1.DataBind();
        }

        
    /// <summary>
        
    /// 功    能:Button1的Click,获得选中的数据的id值
        
    /// 作  者:PUKE
        
    /// 完成时间:2007-05-18
        
    /// 版  权:pukesys@tom.com
        
    /// </summary>
        
    /// <param name="sender"></param>
        
    /// <param name="e"></param>

        protected void Button1_Click(object sender, EventArgs e)
        
    {
            Response.Write(Request.Form.Get(
    "RadioName"));
        }

    }

  • 相关阅读:
    journalctl命令
    systemctl命令
    AgileConfig
    优化 ASP.NET Core Docker 镜像的大小
    ASP.NET Core 集成 React SPA 应用
    使用SQL-Server分区表功能提高数据库的读写性能
    AgileConfig
    用了很多年Dubbo,连Dubbo线程池监控都不知道,觉得自己很厉害?
    Prometheus为你的SpringBoot应用保驾护航
    在冷风中我凌乱了半小时,只因健康码刷不出来
  • 原文地址:https://www.cnblogs.com/puke/p/768664.html
Copyright © 2020-2023  润新知