你看一下官方的demo,或者在search里面搜一下就有了
项目太大不爱打开找

解决方案 »

  1.   

    我试过了demo里的方法,但还是不行,不知道哪出问题了。输出的长度总是为0。
    function grid_SelectionChanged(s,e) {
                s.GetSelectedFieldValues("TT001",GetSelectedFieldValuesCallback);
            }
            function GetSelectedFieldValuesCallback(values) {
                alert(values.length);
            }
      

  2.   

    在GridView鼠标选中行数据使背景色改变、双击某列弹出窗口显示详细信息
    //绑定数据显示数据库数据
     public void BindData()
        {
            string strCon = "server=(local);DataBase=pubs;uid=sa;pwd=;";
            string sqlstr = "select stor_id,stor_name,stor_address,city from stores";
            SqlConnection mycon = new SqlConnection(strCon);
            SqlDataAdapter myda = new SqlDataAdapter(sqlstr, strCon);
            DataSet myds = new DataSet();
            mycon.Open();
            myda.Fill(myds, "stores");
            GridView1.DataSource = myds;
            GridView1.DataKeyNames = new string[] { "stor_id"};
            GridView1.DataBind();
            mycon.Close();
        }
    //从新绑定数据索引
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            BindData(); 
        }
    //双击显示行数据详细信息
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)//判断当前操作的是否是数据行
            {
                e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor='lightBlue'");
                e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;");
                int count = GridView1.Rows.Count;//计算GridView控件的总行数
                string id = "";
                for (int i = 0; i <= count; i++)
                {
                    id = GridView1.DataKeys[i].Value.ToString();//获取当前双击的行的索引值
                    e.Row.Attributes.Add("ondblclick", "javascript:var win=window.open('DisplayDetail.aspx?ID=" + id + "','商品详细页','width=450,height=200,top=176,left=161,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=yes'); win.focus()");
                }
            }    
        } 
      

  3.   

    我用得是ASPxGridView,而且我的问题不是这个。ASPxGridView中这些问题我能解决。不过还是谢谢你!