<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        通過RadioButton對DataList控件進行單選實例說明

        來源:懂視網 責編:小采 時間:2020-11-27 22:41:51
        文檔

        通過RadioButton對DataList控件進行單選實例說明

        通過RadioButton對DataList控件進行單選實例說明:本例實現通過RadioButton對DataList控件進行單選。你可以參考下面演示。 準備好一個星座對象,并定義好一個泛型List來存儲每一個星座名稱。 代碼如下:Constelltion.cs using System; using System.Collections.Generic; us
        推薦度:
        導讀通過RadioButton對DataList控件進行單選實例說明:本例實現通過RadioButton對DataList控件進行單選。你可以參考下面演示。 準備好一個星座對象,并定義好一個泛型List來存儲每一個星座名稱。 代碼如下:Constelltion.cs using System; using System.Collections.Generic; us

        本例實現通過RadioButton對DataList控件進行單選。你可以參考下面演示。
         
        準備好一個星座對象,并定義好一個泛型List來存儲每一個星座名稱。
        代碼如下:

        Constelltion.cs
        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Web;
        /// <summary>
        /// Summary description for Constellation
        /// </summary>
        namespace Insus.NET
        {
        public class Constellation
        {
        private int _ID;
        private string _Name;
        public int ID
        {
        get { return _ID; }
        set { _ID = value; }
        }
        public string Name
        {
        get { return _Name; }
        set { _Name = value; }
        }
        public Constellation()
        {
        //
        // TODO: Add constructor logic here
        //
        }
        public Constellation(int id, string name)
        {
        this._ID = id;
        this._Name = name;
        }
        public List<Constellation> GetConstellation()
        {
        List<Constellation> constellation = new List<Constellation>();
        Constellation c = new Constellation(1, " 白羊座");
        constellation.Add(c);
        c = new Constellation(2, "金牛座");
        constellation.Add(c);
        c = new Constellation(3, "雙子座");
        constellation.Add(c);
        c = new Constellation(4, "巨蟹座");
        constellation.Add(c);
        c = new Constellation(5, "獅子座");
        constellation.Add(c);
        c = new Constellation(6, "處女座");
        constellation.Add(c);
        c = new Constellation(7, "天秤座 ");
        constellation.Add(c);
        c = new Constellation(8, "天蝎座");
        constellation.Add(c);
        c = new Constellation(9, "射手座");
        constellation.Add(c);
        c = new Constellation(10, "摩羯座");
        constellation.Add(c);
        c = new Constellation(11, "水瓶座");
        constellation.Add(c);
        c = new Constellation(12, "雙魚座");
        constellation.Add(c);
        return constellation;
        }
        }
        }

        在.aspx拉一個DataList控件,把RadioButton置于DataList的ItemTemplate模版內。
        代碼如下:

        <asp:DataList ID="DataListConstellation" runat="server" Width="100" CellPadding="0" CellSpacing="0">
        <ItemStyle BorderWidth="1" />
        <ItemTemplate>
        <table>
        <tr>
        <td>
        <asp:RadioButton ID="RadioButtonSelect" runat="server" onclick="SelectedRadio(this);" /></td>
        <td><%# Eval("ID") %></td>
        <td><%# Eval("Name") %></td>
        </tr>
        </table>
        </ItemTemplate>
        </asp:DataList>

        在.aspx.cs內為DataList控件綁定數據:
        代碼如下:

        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Web;
        using System.Web.UI;
        using System.Web.UI.WebControls;
        using Insus.NET;
        public partial class _Default : System.Web.UI.Page
        {
        Constellation objConstellation = new Constellation();
        protected void Page_Load(object sender, EventArgs e)
        {
        if (!IsPostBack)
        Data_Binding();
        }
        private void Data_Binding()
        {
        this.DataListConstellation.DataSource = objConstellation.GetConstellation();
        this.DataListConstellation.DataBind();
        }
        }

        最后,我們寫一段Javascript來實現onclick事件
        代碼如下:

        <script type="text/javascript">
        function SelectedRadio(rb) {
        var gv = document.getElementById("<%=DataListConstellation.ClientID%>");
        var rbs = gv.getElementsByTagName("input");
        var row = rb.parentNode.parentNode;
        for (var i = 0; i < rbs.length; i++) {
        if (rbs[i].type == "radio") {
        if (rbs[i].checked && rbs[i] != rb) {
        rbs[i].checked = false;
        break;
        }
        }
        }
        }
        </script>

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        通過RadioButton對DataList控件進行單選實例說明

        通過RadioButton對DataList控件進行單選實例說明:本例實現通過RadioButton對DataList控件進行單選。你可以參考下面演示。 準備好一個星座對象,并定義好一個泛型List來存儲每一個星座名稱。 代碼如下:Constelltion.cs using System; using System.Collections.Generic; us
        推薦度:
        標簽: 控件 單選 radio
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 亚洲一区二区成人| 亚洲午夜无码AV毛片久久| 精品无码一区二区三区亚洲桃色 | 久久久久国产免费| 亚洲综合熟女久久久30p| 好猛好深好爽好硬免费视频| 亚洲电影日韩精品| 国产免费AV片在线观看播放| 亚洲人成网77777色在线播放| 亚洲美女在线观看播放| 精品无码无人网站免费视频| 亚洲精品91在线| 一二三四免费观看在线电影| 亚洲免费综合色在线视频| 国内永久免费crm系统z在线| 国产av天堂亚洲国产av天堂 | 最近免费中文字幕大全免费版视频| 午夜免费福利网站| 在线视频亚洲一区| 亚洲成av人在片观看| 亚洲天堂2017无码中文| 日韩免费无砖专区2020狼| 亚洲码一区二区三区| a毛片免费在线观看| 亚洲精品亚洲人成在线麻豆| 免费无码又爽又刺激聊天APP| 久久精品7亚洲午夜a| 一级做a爰全过程免费视频毛片| 毛片免费在线视频| 特级aa**毛片免费观看| 亚洲国产三级在线观看| 国产99视频精品免费观看7| 美女裸体无遮挡免费视频网站| 成人免费在线观看网站| 一级毛片在线播放免费| 亚洲色成人网一二三区| 成人永久免费福利视频网站| 国产免费一区二区三区免费视频| 亚洲 自拍 另类小说综合图区 | 亚洲欧好州第一的日产suv| 337p日本欧洲亚洲大胆裸体艺术|