我在Drid的DataBound事件里写:
        if (e.Item.ItemIndex > -1)
        {
            if (e.Item.Cells[6].Text.ToString() == "Url")
            {
                string strUrl = e.Item.Cells[3].Text.ToString();
                e.Item.Cells[2].Text = "<a href=" + strUrl + " target='_blank'>" e.Item.Cells[3].Text.Trim() + "</a>";
            }
            e.Item.Cells[4].Text = e.Item.Cells[4].Text.Trim().Replace("<", "&lt;");
            e.Item.Cells[4].Text = e.Item.Cells[4].Text.Trim().Replace(">", "&gt;");        }这样刚开始是没有问题的,但界面其他按钮只要一点击,item.cell[2]的内容就变成空白了,除非重新绑定一下GRID,我后台跟踪也没有跟踪出来,
想问一下是什么原因造成的.如何解决?
解决倒是想在page_load里再放一次绑定.但真不是个办法~~

解决方案 »

  1.   

    因为item.cell[2]的数据是在绑定过程中定义的数据,并且也没有绑定。
    你可以得到数据集以后对数据进行DataBound的处理,
    例如dataSet.tables(0).rows(0)(1).text="你要定义的值"
    然后直接绑定,不使用DataBound事件,再绑定应该就好用了。
      

  2.   

    TO: dutguoyi(新鲜鱼排)
    THS,一语点醒梦中人啊~~~呵...结贴~~