C#小常识,持续更新..

1.cs部分添加隐藏样式IntegratedEquipmentblock.Style.Add("display", "none");
2.gridview添加奇偶行样式
protected void gvIntegratedEquipmentList_RowDataBound(object sender, GridViewRowEventArgs e)
        {

            //添加样式-----------begin
            switch (e.Row.RowType)
            {
                case DataControlRowType.Header:
                    e.Row.CssClass = "table01_th";
                    break;
                case DataControlRowType.DataRow:
                    if (e.Row.RowIndex > -1)
                    {
                        // 奇数行
                        if (e.Row.RowIndex % 2 == 0)
                        {
                            e.Row.CssClass = "table01_singlar";
                        }
                        else
                        {
                            e.Row.CssClass = "table01_double";
                        }
                    }
                    break;
            }
            //------------------end
        }
3.添加单元格背景色
e.Row.Cells[0].BackColor = (System.Drawing.Color)new WebColorConverter().ConvertFromString("#d0cfce");

 4:

绑定枚举到DropDownList下拉列表的时候:我们知道,可以绑定到下拉列表的有两类对象,一类是实现了IEnumerable接口的可枚举 集合,比如ArrayList,String[],List<T>;一类是实现了IListSource的数据源,比如 DataTable,DataSet。

NOTE:实际上IListSource接口的GetList()方法返回一个IList接口,IList接口又继承了IEnumerable接口。由此看来,IEnumerable是实现可枚举集合的基础

 5:动态添加SELECT无法取值的原因

前台select的动态添加值,是你前台的脚本给添加上的,因此NET的ViewState不会进行处理。在页面加上一个hidden
 <input type='hidden' runat='server' id='hid' />然后给select的动态添加值,同时给hid值改变,这样后台通过取hid值就可以了

原文地址:https://www.cnblogs.com/PeaCode/p/3837672.html