zoukankan      html  css  js  c++  java
  • GridView RadioButton 样板列

    效果图:

    aspx HTML部分:
    --------------
    <script language="javascript" src="Script/SpecialPerform.js"
           type="text/javascript"></script>
    ...
    <asp:GridView ID="gv_SpecialPerformList" runat="server"
         AutoGenerateColumns="False" Width="98%"
         OnRowDataBound="gv_SpecialPerformList_RowDataBound">
       <Columns>
            <asp:TemplateField>
                 <ItemTemplate>                           
                       <asp:RadioButton runat="server" ID="rad_Select"/>
                 </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField HeaderText="专场编号"  DataField="PerformAutoID" >
            </asp:BoundField>
            <asp:BoundField HeaderText="专场名称"  DataField="PerformName" >
            </asp:BoundField>
        </Columns>
    </asp:GridView>
    ...

    aspx cs 部分:
    --------------
        #region 专场列表Grid RowDataBound绑定事件
        protected void gv_SpecialPerformList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowIndex < 0)
                return;
            e.Row.Attributes.Add("onmouseover", "this.style.cursor='hand'");
            e.Row.Attributes.Add("onmouseout", "this.style.cursor=''");
            e.Row.Attributes.Add("onclick", "radButton('" + e.Row.RowIndex.ToString() + "','" + e.Row.Cells[1].Text.Trim() + "');");

        }
        #endregion

    //绑定GridView时
    //保存本次数据的条数
    this.hidtxt_gvSPListRowCount.Text = dt.Rows.Count.ToString();

    JS 部分:
    --------
    function radButton(rowIndex,rowPerformAutoID)
    {
        //id="gv_SpecialPerformList_ctl02_rad_Select"
        var rowCount = parseInt(document.all.hidtxt_gvSPListRowCount.value)+2;
       
        for(var i=2;i<rowCount;i++)
        {
            var tmpName;
            if(i<10)
            {
                tmpName = "gv_SpecialPerformList_ctl0"+i+"_rad_Select";               
            }
            else
            {
                tmpName = "gv_SpecialPerformList_ctl"+i+"_rad_Select";   
            }
            //取得对应的Radio对象
            var tmpRadio = document.getElementById(tmpName);
            //当前选中 其他取消选中
            if((i-2) == rowIndex)
            {                 
                tmpRadio.checked = true;
            }
            else
            {
                tmpRadio.checked = false;
            }
        }
        document.all.hidtxt_PerformAutoID.value = rowPerformAutoID;
    }

  • 相关阅读:
    git
    java网络
    配置本地git服务器(gitblit win7)
    atom 插件安装【转载】
    javaIo
    如何在eclipse中设置断点并调试程序
    如何将工程推到github上
    git操作记录
    编码
    node升级7.0以上版本使用gulp时报错
  • 原文地址:https://www.cnblogs.com/freeliver54/p/1116075.html
Copyright © 2011-2022 走看看