zoukankan      html  css  js  c++  java
  • 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"));
        }

    }

  • 相关阅读:
    团队项目简介及视频
    构建之法阅读笔记04
    软件工程结对作业02
    团队项目NABCD
    搜狗输入法人机交互设计的用户体验
    站立会议个人博客5(2016/4/23)
    站立会议个人博客4(2016/4/22)
    典型用户和用户场景描述
    站立会议个人博客3(2016/4/21)
    站立会议个人博客2(2016/4/20)
  • 原文地址:https://www.cnblogs.com/puke/p/768664.html
Copyright © 2011-2022 走看看