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();
原文地址:http://www.cnblogs.com/115FXC/p/3864639.html