• 后台给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方法
    }
    }

  • 相关阅读:
    java数据类型转换
    复习Java基础
    最完整的台达PLC培训教程(沈阳工大)学习笔记1
    6.3.4 方法引用
    6.3.3函数式接口
    6.3 lambda 表达式
    java 核心技术卷一笔记 6 .2.3 接口 lambda 表达式 内部类
    java 核心技术卷一笔记 6 .2接口 lambda 表达式 内部类
    java 核心技术卷一笔记 6 .1.接口 lambda 表达式 内部类
    软件开发需求风险分析
  • 原文地址:https://www.cnblogs.com/hjianguo/p/5522499.html
Copyright © 2020-2023  润新知