比如:GridView1_RowDataBound(Object sender, GridViewRowEventArgs e) 事件过程是:if(e.Row.RowType == DataControlRowType.DataRow)
    {
      
      e.Row.Cells[1].Text = "<i>" + e.Row.Cells[1].Text + "</i>";
           //执行某种操作
    }
我想把它写到一个类中,当做方法调用。比如写到数据访问层中的DAL.SCTB.zhixing方法中public void zhixing(Object sender, GridViewRowEventArgs e)
{
   e.Row.Cells[1].Text = "<i>" + e.Row.Cells[1].Text + "</i>";}出现错误提示:  GridViewRowEventArgs没有命名空间。我在网上查了一下它的命名空间是:System.Web.UI.WebControls
在上面引用了一下:using System.Web.UI.WebControls;   还是错误提示 System.Web下面没有UI....

解决方案 »

  1.   

    .cs中默认情况下不是已经有using System.Web.UI.WebControls; 了吗?奇怪
      

  2.   

    你的数据访问层是单独的Assembly吧?那就需要手动添加对System.Web的引用。
      

  3.   

    不能这么写吧,这样有点"偏题"了.非得这样,我觉得你应该在原来的View中再写一个方法,把GridView1_RowDataBound(Object sender, GridViewRowEventArgs e)做个包装,然后再在DAL中调用这个方法...
      

  4.   

    对的...lz的想法不是“偏题”而是违反了“依赖倒置”原则...无论你怎么写,只要把GridViewRowEventArgs带进去都是不可取的...正确的做法是这样...
    if(e.Row.RowType == DataControlRowType.DataRow) 
    {
       //这里还要加上检测e.Row.Cells是否有索引1和索引1是否为null的代码避免异常
       e.Row.Cells[1].Text = do(e.Row.Cells[1].Text); 
    }public string do(string value)
    {
    ...
    }
      

  5.   

    public TEventArgs:EventArgs
    {
    .....
    }
    public delegate TEventHandler(object o,TEventArgs e);
    public class a
    {
    .....
    public event CellChanged;
    }写错了别笑,很久没用了。1