• 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"));
        }

    }

  • 相关阅读:
    MongoDB 学习笔记之 MongoDB导入导出
    快学Scala 第十四课 (读取行,读取字符, 控制台读取)
    MongoDB 学习笔记之 权限管理基础
    MongoDB 学习笔记之 索引
    MongoDB 学习笔记之 游标
    MongoDB 学习笔记之 查询表达式
    MongoDB 学习笔记之 基本CRUD
    MongoDB 学习笔记之 入门安装和配置
    Eclipse设置JVM的内存参数
    cron表达式详解
  • 原文地址:https://www.cnblogs.com/puke/p/768664.html
Copyright © 2020-2023  润新知