当前位置: 代码迷 >> ASP.NET >> 请教下这么做有什么好处,不用数据控件,全部自己拼TABLE,小弟我现在改的烦的要死
  详细解决方案

请教下这么做有什么好处,不用数据控件,全部自己拼TABLE,小弟我现在改的烦的要死

热度:1434   发布时间:2013-02-25 00:00:00.0
请问下这么做有什么好处,不用数据控件,全部自己拼TABLE,我现在改的烦的要死。
接手一项目
不知道是谁写的
所有显示数据的地方,全是用TABLE做的,拼HtmlTableRow,HtmlTableCell这么写的
我就想不通了,挺简单的一东西,直接搞GRIDVIEW不就完了嘛
莫非这么做有什么好处?
现在要改点功能什么的真难受
随便贴点代码,这个项目显示数据大概就类似是这么做的:
C# code
        private void LoadEmployeeData()    {        M_Employee employee= new M_Employee();        employee.Where.Resign_date.Operator = WhereParameter.Operand.IsNull;        if (employee.Query.Load())        {            lblWarning.Visible = false;            HtmlTableRow r;            do            {                r = new HtmlTableRow();                for (int i = 0; i < 18; i++)                {                    r.Cells.Add(GetTableCell(employee, i));                }                tblData.Rows.Add(r);            }            while (employee.MoveNext());        }        else        {            lblWarning.Visible = true;            lblWarning.Text = "No Data found!";        }    }    private HtmlTableCell GetTableCell(M_Employee obj, int column)    {        HtmlTableCell c;        c = new HtmlTableCell();        switch (column)        {            case 0:                if (Master.Level > 1)                {                    c.InnerHtml =                      "<a href=\"javascript:OpenPopup('600','480','EditEmployee.aspx" +                      "?employeeid=" + obj.Employee_id +                      "');\">" + obj.Employee_id + "</a>";                }                else                    c.InnerText = obj.Employee_id;                break;            case 1:                c.InnerText = selectCompanyName(obj.Company_id);                break;            case 2:                c.InnerText = selectDepartmentName(obj.Department_id);                break;            case 3:                c.InnerText = selectDivisionName(obj.Division_id);                break;            case 4:                c.InnerText = selectGroupName(obj.Group_id);                break;            case 5:                c.InnerText = obj.Last_name.Trim() + obj.First_name.Trim();                break;            case 6:                if (obj.Sex)                    c.InnerText = "男";                else                    c.InnerText = "女";                break;            case 7:              c.InnerText = obj.Ablity;                break;            case 8:                c.InnerText = obj.Duty;                break;            case 9:                if (obj.s_Married == string.Empty)                    c.InnerHtml = "&nbsp;";                else if (obj.Married)                    c.InnerText = "已婚";                else                    c.InnerText = "未婚";                break;            case 10:                c.InnerText = obj.Degree.Trim();                break;            case 11:                if (obj.IsColumnNull(M_Employee.ColumnNames.Birthday))                  c.InnerHtml = "&nbsp;";                else                     c.InnerText = obj.Birthday.ToString("yyyy/MM/dd");                break;            case 12:                c.InnerText = obj.Telephone.Trim();                break;            case 13:                c.InnerText = obj.Mobile;                break;            case 14:                c.InnerText = obj.Address.Trim();                break;            case 15:                if (obj.s_Transtype == string.Empty)                    c.InnerHtml = "&nbsp;";                else if (obj.Transtype == 0)                    c.InnerText = "不坐班车";                else if (obj.Transtype == 1)                    c.InnerText = "坐班车";                break;            case 16:                if (obj.IsColumnNull(M_Employee.ColumnNames.Resign_date))                  c.InnerHtml = "&nbsp;";                else                    c.InnerText = obj.Resign_date.ToString("yyyy/MM/dd");                break;            case 17:                c.InnerText = obj.Remark.Trim();                break;            default:                break;        }        if (string.IsNullOrEmpty(c.InnerHtml))        {            c.InnerHtml = "&nbsp;";        }        c.Align = "center";        return c;    }
  相关解决方案