protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
((DropDownList)this.FormView1.FindControl("DropDownList1")).Items.Clear();
((DropDownList)this.FormView1.FindControl("DropDownList6")).Items.Clear(); int k = 0;
for (k = 0; k < 24; k++)
{
((DropDownList)this.FormView1.FindControl("DropDownList1")).Items.Add(k.ToString());
((DropDownList)this.FormView1.FindControl("DropDownList6")).Items.Add(k.ToString());
}
((DropDownList)this.FormView1.FindControl("DropDownList2")).Items.Clear();
((DropDownList)this.FormView1.FindControl("DropDownList7")).Items.Clear(); int r = 0;
for (r = 0; r < 60; r++)
{
((DropDownList)this.FormView1.FindControl("DropDownList2")).Items.Add(r.ToString());
((DropDownList)this.FormView1.FindControl("DropDownList7")).Items.Add(r.ToString());
} ((LinkButton)this.FormView1.FindControl("InsertButton")).Attributes.Add("onclick", "javascript:if(confirm('确定要添加吗?')){}else{return false;}");
}
}
protected void InsertButton_Click(object sender, EventArgs e)
{
//插入日期
((HiddenField)this.FormView1.FindControl("HiddenField1")).Value = ((Meta.Web.Controls.DropDownCalendar)this.FormView1.FindControl("FreeDate")).Value.ToString("d");
//插入录入人员
((HiddenField)this.FormView1.FindControl("SerPerson")).Value = Session["StaffName"].ToString();
// 插入录入时间;
((HiddenField)this.FormView1.FindControl("SerDate")).Value = DateTime.Now.ToString();
//插入各起止时间
((HiddenField)this.FormView1.FindControl("FreeTime")).Value = (((DropDownList)this.FormView1.FindControl("DropDownList1")).Text) + ":" + (((DropDownList)this.FormView1.FindControl("DropDownList2")).Text);
((HiddenField)this.FormView1.FindControl("OutTime")).Value = (((DropDownList)this.FormView1.FindControl("DropDownList6")).Text) + ":" + (((DropDownList)this.FormView1.FindControl("DropDownList7")).Text);
}
这些就是编辑页面的代码。麻烦看一下有没有错误!
{
if (!IsPostBack)
{
((DropDownList)this.FormView1.FindControl("DropDownList1")).Items.Clear();
((DropDownList)this.FormView1.FindControl("DropDownList6")).Items.Clear(); int k = 0;
for (k = 0; k < 24; k++)
{
((DropDownList)this.FormView1.FindControl("DropDownList1")).Items.Add(k.ToString());
((DropDownList)this.FormView1.FindControl("DropDownList6")).Items.Add(k.ToString());
}
((DropDownList)this.FormView1.FindControl("DropDownList2")).Items.Clear();
((DropDownList)this.FormView1.FindControl("DropDownList7")).Items.Clear(); int r = 0;
for (r = 0; r < 60; r++)
{
((DropDownList)this.FormView1.FindControl("DropDownList2")).Items.Add(r.ToString());
((DropDownList)this.FormView1.FindControl("DropDownList7")).Items.Add(r.ToString());
} ((LinkButton)this.FormView1.FindControl("InsertButton")).Attributes.Add("onclick", "javascript:if(confirm('确定要添加吗?')){}else{return false;}");
}
}
protected void InsertButton_Click(object sender, EventArgs e)
{
//插入日期
((HiddenField)this.FormView1.FindControl("HiddenField1")).Value = ((Meta.Web.Controls.DropDownCalendar)this.FormView1.FindControl("FreeDate")).Value.ToString("d");
//插入录入人员
((HiddenField)this.FormView1.FindControl("SerPerson")).Value = Session["StaffName"].ToString();
// 插入录入时间;
((HiddenField)this.FormView1.FindControl("SerDate")).Value = DateTime.Now.ToString();
//插入各起止时间
((HiddenField)this.FormView1.FindControl("FreeTime")).Value = (((DropDownList)this.FormView1.FindControl("DropDownList1")).Text) + ":" + (((DropDownList)this.FormView1.FindControl("DropDownList2")).Text);
((HiddenField)this.FormView1.FindControl("OutTime")).Value = (((DropDownList)this.FormView1.FindControl("DropDownList6")).Text) + ":" + (((DropDownList)this.FormView1.FindControl("DropDownList7")).Text);
}
这些就是编辑页面的代码。麻烦看一下有没有错误!
里面的代码中设置断点,看看执行到哪里就会出现问题。用个try catch 来捕获该异常。