楼上你说的是JS吧,我是要在后台获取,用的是C#。

解决方案 »

  1.   

    要不在每一格中添加一个Label控件,给其Text赋值,再通过得到Label的Text值累加
      

  2.   

    你跟踪一下看你要取tableCell值的时候,cell还有没有了,table的创建要放到!Page.IsPostBack的外面
      

  3.   

    我是用下面的语句做循环给cell赋值的
    rowResult.Cells[i].Text  = rdEgood[0].ToString().Trim();现在我想取cell的值
    String temp = tbResult.Rows[0].Cells[1].Text;可是取出来都是空的,可是我输出tbResult的行数是正确的,说明tbResult
    已经构造和赋值好了呀!
      

  4.   

    找到问题了,现在想请教一下怎么定义一个tablerow使它成为rowResult的第一行?
    TableRow rowResult = tbResult.Rows[0];
    上面的写法是错误的!
      

  5.   

    String temp = tbResult.Rows[0].Cells[1].Text;
    这样不行,取出来是空的,
    tbResult.Rows[0].Cells[1].Text = "ddddddd";
    这样就可以,可以设置单元格的值。
    可是我看帮助说Text是设置和获取Cell的值呀?
      

  6.   

    have you tried YourTable.Rows.AddAt(0,YourTableRow)?
      

  7.   

    saucer(思归/MVP),
    你说的是增加第一行,没有问题,我现在是已经有了第一行,
    可以更改第一行每一个Cell的值,但是就是没法获取它的值,
    为什么?
      

  8.   

    show your code, or try         Table t = new Table();
    TableRow tr = new TableRow();
    TableCell tc = new TableCell();
    tc.Text = "abc";
    tr.Cells.Add(tc);
    t.Rows.Add(tr);
    Response.Write("***" + t.Rows[0].Cells[0].Text + "***");
      

  9.   

    tbResult.Rows[0].Cells[0].Controls有多少?
      

  10.   

    saucer(思归/MVP),
    我单独在一个页面照你这么写可以获取text的值,
    可是在我自己的页面就不行,区别就是我定义了一个全局变量
    Table tbResult;
    然后在不同的函数中操作tbResult这个对象,以下是我主要的程序
    private void ConstructTable(ref string refQuerySQL)
    {
       TableRow rowResult = new TableRow();
       string strTmp="\\NULL//",strTmp2="";
       OleDbCommand commSQL = new OleDbCommand(refQuerySQL,dbConnection);
       OleDbDataReader rdEgood = commSQL.ExecuteReader();
       while(rdEgood.Read())
       {
           strTmp2 = rdEgood[1].ToString().Trim();
           if(strTmp!=strTmp2)//insert a row
           {
    tbResult.Rows.Add(rowResult);
    rowResult = new TableRow();
    nAltermate = (++nAltermate%2);
    if(nAltermate==1)
       rowResult.BackColor = Color.AliceBlue;
    else
       rowResult.BackColor = Color.White; 
    InsertCell("LightGray",rdEgood[4].ToString().Trim(),ref rowResult);
    InsertCell("LightGray",rdEgood[5].ToString().Trim(),ref rowResult);
    InsertCell("LightGray","",ref rowResult);
    InsertCell("LightGray",rdEgood[6].ToString().Trim(),ref rowResult);
    InsertCell("LightGray",rdEgood[1].ToString().Trim(),ref rowResult);
    InsertCell("LightGray",rdEgood[2].ToString().Trim(),ref rowResult);
    InsertCell("LightGray","",ref rowResult);
    for(int i=7;i<arrHead.Count;i++) //fill with space for each cell
                   InsertCell("","",ref rowResult);
    strTmp = strTmp2;
           }
           for(int i=7;i<arrHead.Count;i++)//update cell(amount) to fit position
           {
     if(arrHead[i].ToString().Trim() == rdEgood[3].ToString().Trim())
    {
        rowResult.Cells[i].Text  = rdEgood[0].ToString().Trim();
                 rowResult.Cells[i].ToolTip = rdEgood[2].ToString().Trim()+"(机型:"+arrHead[i].ToString().Trim()+")";
        rowResult.Cells[i].Wrap = false;
    }
           }
         }
        tbResult.Rows.Add(rowResult);
        rdEgood.Close();
        commSQL.Dispose();
    }
      

  11.   

    执行完上面的代码,我的table就构造完了,现在我想取tableCell的值,
    但是就是取不出来,不明白为什么?
      

  12.   

    把你调用的编码贴出来,或者自己Debug看tbResult其中内容变化