梓骏

导航

根据Gridviwe某列的值显示不同效果 空格效果 背景色效果

if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DataRowView row = (DataRowView)e.Row.DataItem;//当前行的数据

                //if (e.Row.Cells[1].Text.StartsWith("51"))某列以值开头的
                if (e.Row.Cells[1].Text.Length == 4)

                    e.Row.Cells[2].Text = e.Row.Cells[2].Text;

                if (e.Row.Cells[1].Text.Length == 6)

                    e.Row.Cells[2].Text = " " + e.Row.Cells[2].Text;

                if (e.Row.Cells[1].Text.Length == 8)

                    e.Row.Cells[2].Text = "  " + e.Row.Cells[2].Text;

                if (e.Row.Cells[1].Text.Length == 10)

                    e.Row.Cells[2].Text = "   " + e.Row.Cells[2].Text;
                if (e.Row.Cells[1].Text.Length == 12)

                    e.Row.Cells[2].Text = "    " + e.Row.Cells[2].Text;


                //光标效果
                e.Row.Attributes.Add("onmouseover", "color = this.style.backgroundColor;this.style.backgroundColor='#6a6868';this.style.cursor= 'hand';this.title='双击查看详细信息.'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=color");
                //事件绑定
            }

posted on 2012-10-15 10:15  梓骏  阅读(226)  评论(0编辑  收藏  举报