C#学习笔记

下拉列表的规范命名   绑定下拉列表  一般格式是 databindDropDownList(为你的 下拉列表的ID)

list 也可以绑定  ddl

list datatable 的 转换应该放  数据访问层 不要放页面

            Entities.Students stu =null ;
            if (IsAddNew)
            {

                string un = tb_tsid.Text;
                Stu.BLL.Students bstu = new Stu.BLL.Students();
                bool hasvalue = bstu.ExistsUN(un);
                if (hasvalue == true)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "js", "f_false()", true);
                    return;
                }
                else  完全可以这样写 搞那么多if else 会使得你的代码可读性很差
                {
                    stu = new Entities.Students();
                }
            }

可以写成 下面的代码。增强代码可读性

Entities.Students stu =new Entities.Students();
if (IsAddNew)
{

string un = tb_tsid.Text;
Stu.BLL.Students bstu = new Stu.BLL.Students();
bool hasvalue = bstu.ExistsUN(un);
if (hasvalue == true)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "js", "f_false()", true);
return;
}
//else 完全可以这样写 搞那么多if else 会使得你的代码可读性很差
//{
//stu = new Entities.Students();
//}
}

posted on 2011-11-21 23:00  菜鸟小粽粽  阅读(99)  评论(0)    收藏  举报

导航