• GridView点击一行 取数据


    1.后台添加点击事件
    protected
     void gvadm_RowDataBound(object sender, GridViewRowEventArgs e)         {             this.lblCurrentPage.Text = string.Format("当前第{0}页/总共{1}页"this.gvm.PageIndex + 1, this.gvm.PageCount);             //遍历所有行设置边框样式               foreach (TableCell tc in e.Row.Cells)             {                 tc.Attributes["style"] = "border-color:#D9ECFB";             }             if (e.Row.RowIndex != -1)             {                 int id = e.Row.RowIndex + 1;                 e.Row.Cells[0].Text = id.ToString();             }             //执行循环,保证每条数据都可以更新             for (int i = 0; i < gvm.Rows.Count + 1; i++)             {                 //首先判断是否是数据行                 if (e.Row.RowType == DataControlRowType.DataRow)                 {                     //当鼠标停留时更改背景色                     e.Row.Attributes.Add("onmouseover""c=this.style.backgroundColor;this.style.color='red';this.style.backgroundColor='#D9ECFB'");                     //当鼠标移开时还原背景色                     e.Row.Attributes.Add("onmouseout""this.style.backgroundColor=c;this.style.color='black';this.style.backgroundColor=c");                     e.Row.Attributes.Add("id""row_" + i.ToString());                     e.Row.Attributes.Add("onclick""Item_Click(this)");                     e.Row.Attributes["style"] = "Cursor:pointer";                 }             }         }
    2.前台赋值
    <script type="text/javascript">
            function Item_Click(item) {
                $("#txtCapability").attr("value", item.cells[2].innerText);
                $("#txtAH").attr("value", item.cells[5].innerText);
                $("#txtFOH").attr("value", item.cells[8].innerText);
                $("#txtGAAG").attr("value", item.cells[3].innerText);
                $("#txtSH").attr("value", item.cells[6].innerText);
                $("#txtEUNDH").attr("value", item.cells[9].innerText);
                $("#txtPH").attr("value", item.cells[4].innerText);
                $("#txtUOH").attr("value", item.cells[7].innerText);
            }
        </script>
  • 相关阅读:
    我对NHibernate的感受(3):有些尴尬的集合支持
    NHibernate3.0剖析:Query篇之NHibernate.Linq标准查询
    NHibernate3.0剖析:Query篇之NHibernate.Linq增强查询
    30个优秀的后台管理界面设计案例分享
    NHibernate Session Flush的作用
    NHibernate 3 Extending the Linq Provider to fix some System.NotSupportedException
    Activity初步
    公司间交易学习笔记概述
    公司间交易学习笔记值映射
    BOM配置
  • 原文地址:https://www.cnblogs.com/bfy-19/p/3160772.html
Copyright © 2020-2023  润新知