asp.net后台的一些操作

1.在后台绑定下拉框再返回到前台

protected StringBuilder sq = new StringBuilder();//为了在前台绑定

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

MakeTypeSelect();
}
}
//定义办法
private void MakeTypeSelect()
{
var typeList = typeBll.GetModelList("");
if (typeList.Count > 0)
{

sq.Append("<select name=\"type\">");
for (int i = 0; i < typeList.Count; i++)
{
sq.Append("<option value=\"" + typeList[i].ID + "\">" + typeList[i].ConsumableType + "</option>");
}
sq.Append("</select>");

}
}

 

2.做新增时自定义ID为日期类型
model.ID ="SJHCSG"+ DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second + DateTime.Now.Millisecond.ToString();

posted @ 2014-07-24 07:33  阳光代码  阅读(246)  评论(0编辑  收藏  举报