zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    centos7 忘记mysql5.7密码
    阿里云Linux(Centos7)下搭建SVN服务器
    JAVA金额格式字符串转数值
    win10下RabbitMQ的安装和配置
    Oracle update 两表及以上关联更新,出现多值情况,不是一对一更新
    java.lang.OutOfMemoryError: java heap space
    bootstrap.min.css.map
    css 边距等常用设置
    html 标签
    数据库总结
  • 原文地址:https://www.cnblogs.com/bfy-19/p/3160772.html
Copyright © 2011-2022 走看看