zoukankan      html  css  js  c++  java
  • 单击GridView的某一行 根据此行id得到这行的所有信息

    1.在源的第一行<%@ Page ....%>中添加 EnableEventValidation="false"
    2.注意项:若根据id得到点击行的详细信息 则id必须存在GridView中,用隐藏控件接收id的值 如图

    3.在GridView1_RowDataBound事件中写入行的onclick事件
     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Cells[3].Text = e.Row.Cells[3].Text.ToString().Substring(0, 8) + "......";
                ((LinkButton)e.Row.Cells[6].Controls[0]).Attributes.Add("onclick", "return confirm('是否要删除此

    行?')");
                e.Row.Attributes["OnClick"] =ClientScript.GetPostBackEventReference(e.Row.Parent.Parent, "Select$" +

    e.Row.RowIndex);
                //e.Row.Attributes.Add("onclick", "t=this.style.backgroundColor;this.style.backgroundColor='#ebebce'");
                //e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=t");
                //e.Row.Attributes.CssStyle.Add("cursor", "hand");

            }
        }
    4.在GridView1_SelectedIndexChanged中写点击行的代码
      protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridView grv = (GridView)sender;
            if (grv.SelectedRow.RowType == DataControlRowType.DataRow)
            {
                if (grv.SelectedIndex != -1)
                {
                    int id =Convert.ToInt32(((HiddenField)grv.Rows[grv.SelectedIndex].FindControl("idd")).Value.ToString());
                    DataSet ds = op.SelectInfo("招聘信息", id);
                    DataTable dt = ds.Tables[0];
                    TextBox1.Text = dt.Rows[0][0].ToString();
                }
            }
        }

  • 相关阅读:
    js关于页面坐标api
    js面向对象之创建对象
    Web前端安全问题
    js操作cookie
    css清除浮动
    块级格式化上下文(block formatting context)
    《python核心编程》笔记——系统限制
    《python核心编程》笔记——文件的创建、读取和显示
    黑客们的故事连载十二 “蠕虫来袭”:莫里斯
    黑客们的故事连载十一 下村努—虚拟战争追逐
  • 原文地址:https://www.cnblogs.com/MyBeN/p/1981553.html
Copyright © 2011-2022 走看看