我今天试着用VS2005,发现一些简单问题都解决不了,起级的烦恼,请各位帮忙看看:
1、<Table width="800" align="center"></Table>它说这个不对呀,属性"align"已过时,建议使用较新的构造,但我找了一下,没有Table的其它写法可以居中呀?CSS也控制不了呀?2、我在用GridView时发现,它真不错,绑定不用写代码,就算是存储过程也不用写代码!牛!翻页也不用写代码!但问题是我在以前datagrid里用的鼠标走到哪行,哪行就变色的代码不能用了:
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            //添加自定义属性,当鼠标移过来时设置该行的背景色为"6699ff",并保存原背景色
            e.Item.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#C6C3C6'");
            //添加自定义属性,当鼠标移走时还原该行的背景色
            e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");        }
因为找不到ItemDataBind这个了,有人说是用RowDataBind替代了,但我也在那里找不到e.Item呀?怎么做呢?各位在用VS2005时是不是也有很多问题呢??我们需不需要升级到VS2005呀???现在我下载了很多VS2005,有TEAM的,有PRO的,但它们的SETUP.INI里都写着beta2,是不是正式版还没有出来呀??

解决方案 »

  1.   

    第1个问题,试过没问题。那个是HTML的,2005应该不会去改变这个的。2:
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //添加自定义属性,当鼠标移过来时设置该行的背景色为"6699ff",并保存原背景色
            e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#C6C3C6'");
            //添加自定义属性,当鼠标移走时还原该行的背景色
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
        }
      

  2.   

    版本:
    Microsoft Visual Studio 2005 8.0.50727.42。
      

  3.   

    1、css是可以控制表格居中的,两种方法,
    其一是在表格父元素引用的css中设置text-align:center;
    其二是在表格的引用的css中设置 myalign:expression(this.align="center");
      

  4.   

    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {}
    换成
    if (e.Row.RowType == DataControlRowType.DataRow)
            { }