0
我有一個formview的負載事件只是決定停止工作。我做了一些調試,發現它到達代碼,但無論什麼原因,我在加載事件中添加的屬性不再顯示在屏幕上。就好像在formview的加載事件之後發生了一些事情,在沒有任何額外屬性的情況下重新加載它。我在停止工作之前完成的唯一修改是在它之前的頁面中添加了一個會話變量。這不應該導致如此劇烈的變化。FormView_Load被覆蓋C#ASP.NET
這裏是我的代碼:
protected void FormView1_Load(object sender, EventArgs e)
{
RadioButton rbinjury = (RadioButton)FormView1.FindControl("rbinjury");
RadioButton rbproperty = (RadioButton)FormView1.FindControl("rbproperty");
RadioButton rbboth = (RadioButton)FormView1.FindControl("rbboth");
RadioButton rbyes = (RadioButton)FormView1.FindControl("rbyes");
RadioButton rbno = (RadioButton)FormView1.FindControl("rbno");
RadioButton rbyes2 = (RadioButton)FormView1.FindControl("rbyes2");
RadioButton rbno2 = (RadioButton)FormView1.FindControl("rbno2");
RadioButton rbam = (RadioButton)FormView1.FindControl("rbam");
RadioButton rbpm = (RadioButton)FormView1.FindControl("rbpm");
TextBox txtdate = (TextBox)FormView1.FindControl("txtdate");
DropDownList ddlhour = (DropDownList)FormView1.FindControl("ddlhour");
DropDownList ddltime = (DropDownList)FormView1.FindControl("ddltime");
if (FormView1.CurrentMode == FormViewMode.Insert || FormView1.CurrentMode == FormViewMode.Edit)
{
txtdate.Attributes.Add("onfocus", "unfocus();");
locList.Attributes.Add("onChange", "postBack();");
ddlhour.Items.Insert(0, new ListItem("Hour", "0"));
ddlhour.Items.Insert(1, new ListItem("12", "12"));
ddltime.Items.Insert(0, new ListItem("Minute", "0"));
for (int i = 1; i < 12; i++)
{
String hour = Convert.ToString(i);
ddlhour.Items.Add(new ListItem(hour, hour));
}
for (int i = 0; i < 61; i++)
{
String time = "";
if (i < 10)
{
time = ":0" + Convert.ToString(i);
}
else
{
time = ":" + Convert.ToString(i);
}
ddltime.Items.Add(new ListItem(time, time));
}
//-----------------------------------------handle radio buttons----------------------------------------------------------------
rbinjury.Attributes.Add("Onclick", "radio('rbinjury','result');");
rbproperty.Attributes.Add("Onclick", "radio('rbproperty','result');");
rbboth.Attributes.Add("Onclick", "radio('rbboth','result');");
rbyes.Attributes.Add("Onclick", "radio('rbyes','inj');");
rbno.Attributes.Add("Onclick", "radio('rbno','inj');");
rbyes2.Attributes.Add("Onclick", "radio('rbyes2','dmg');");
rbno2.Attributes.Add("Onclick", "radio('rbno2','dmg');");
rbam.Attributes.Add("Onclick", "radio('rbam','time');");
rbpm.Attributes.Add("Onclick", "radio('rbpm','time');");
}}
任何想法會導致負載情況下停止工作?如果我在頁面的保存狀態完成事件中放置相同的代碼,它確實有效,但我不應該...