zoukankan      html  css  js  c++  java
  • 后台给GridView绑定数据时给每一行添加一个JS方法

    --------JS

    function ReturnDictionaryValues(srcElement)
    {
    top.document.getElementById("_DialogFrame_a1").contentWindow.document.getElementById('txt_CAR_ID').value=srcElement.cells[0].innerText;
    top.document.getElementById("_DialogFrame_a1").contentWindow.document.getElementById('CAR_NO').innerText=srcElement.cells[3].innerText;
    top.document.getElementById("_DialogFrame_a1").contentWindow.document.getElementById('txt_Unit').innerText=srcElement.cells[1].innerText;
    top.document.getElementById("_DialogFrame_a1").contentWindow.gongmu();//执行上一个页面的gongmu()方法
    top.Dialog.close();//关闭当前页面
    }

    --------GridView

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" class="tableStyle" DataKeyNames="CAR_ID" border="0" Style=" 100%" ToolTip="双击进行选择" OnRowDataBound="gv_RowDataBound">
    <Columns>
    <asp:BoundField DataField="CAR_NUM" HeaderText="车牌号">
    <ItemStyle HorizontalAlign="Center" Width="10%" />
    <HeaderStyle HorizontalAlign="Center" />
    </asp:BoundField>
    <asp:TemplateField HeaderText="所属单位">
    <ItemTemplate><%#new AS_Services.BLL.PU_STATION().GetModel(Eval("STATION_ID").ToString()).STATION_NAME%> </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="汽车类型">
    <ItemTemplate><%#new AS_Services.BLL.PB_DZ_KIND().GetModel(Eval("KIND_ID").ToString()).KIND_NAME%> </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    <EmptyDataTemplate>
    暂无记录!</EmptyDataTemplate>
    </asp:GridView>

    ---------GridView页面的后台

    protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    e.Row.Attributes.Add("ondblclick", "ReturnDictionaryValues(this);");//每行添加一个ReturnDictionaryValues()的JS方法
    }
    }

  • 相关阅读:
    nginx基础系列
    常用MS-SQL写法整理
    Spring Bean装配方式
    sql获取该周的开始结束日期
    Docker基础入门实践
    vim常规操作
    基于CentOS的SSHD服务的Docker镜像
    RedisClient For .Net
    Redis数据类型及使用场景
    CentOS下安装Redis
  • 原文地址:https://www.cnblogs.com/hjianguo/p/5522499.html
Copyright © 2011-2022 走看看