我用.getElementById进行访问,提示不可以,难道必须是模版列才能访问吗?

解决方案 »

  1.   

    就是想通过javascript在客户端,读取gridview数据绑定列里的数据进行运算,数据绑定列不是在模板列里的
      

  2.   


    服务端写
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType = DataControlRowType.DataRow)
            {
                decimal decCol1=string.IsNullOrEmpty(e.Row.Cells[1].Text)?0.00M:Convert.ToDecimal(e.Row.Cells[1].Text);
                decimal decCol2=string.IsNullOrEmpty(e.Row.Cells[2].Text)?0.00M:Convert.ToDecimal(e.Row.Cells[2].Text);
                decimal amt=decCol1-decCol2;
                e.Row.Cells[0].Text = amt.ToString("N2");
            }
        }客户端可以var txt =document.getElementById("grid1").rows[r].cells[0].innerText;
      

  3.   

    e.Row.RowType = DataControlRowType.DataRow==>e.Row.RowType == DataControlRowType.DataRow
      

  4.   

    在服务器端写个方法   获取GridView中的值  然后再客户端调用服务器端的方法就是了