我有一個單選按鈕單選按鈕選中不觸發正確
<asp:RadioButton ID="AMRadioButton" runat="server" AutoPostBack="True" GroupName="TypeGroup"
OnCheckedChanged="AMRadioButton_CheckedChanged" Text="Accounting Date" />
<asp:RadioButton ID="LMRadioButton" runat="server" AutoPostBack="True" GroupName="TypeGroup"
OnCheckedChanged="LMRadioButton_CheckedChanged" Text="Loan Date" />
和我身後
protected void AddButton_Click(object sender, EventArgs e)
{
if (AMRadioButton.Checked = true)
{
prenda.Bcode = BranchCodetxtbox.Text;
prenda.AccountingMonth = YearDropDownList.SelectedValue + "/" + MonthDropDownList.SelectedValue;
prenda.Jprincipal = Convert.ToDecimal(JewelryTextBox.Text);
prenda.Aprincipal = Convert.ToDecimal(ApplianceTextBox.Text);
prenda.Cprincipal = Convert.ToDecimal(CellphoneTextBox.Text);
user.UserID = Session["UserID"].ToString();
servs.UploadPrendaAM(prenda, user);
Session["Count"] = "1";
Response.Write("<script language='javascript'>window.alert('Success!');window.location='DataEntryPage.aspx';</script>");
}
else if (LMRadioButton.Checked = true)
{
prenda.Bcode = BranchCodetxtbox.Text;
prenda.LoanMonth = YearDropDownList.SelectedValue + "/" + MonthDropDownList.SelectedValue;
prenda.Jprincipal = Convert.ToDecimal(JewelryTextBox.Text);
prenda.Aprincipal = Convert.ToDecimal(ApplianceTextBox.Text);
prenda.Cprincipal = Convert.ToDecimal(CellphoneTextBox.Text);
user.UserID = Session["UserID"].ToString();
servs.UploadPrendaLM(prenda, user);
Session["Count"] = "1";
Response.Write("<script language='javascript'>window.alert('Success!');window.location='DataEntryPage.aspx';</script>");
}
}
問題的一個代碼,即使我已經檢查/選擇的LMradiobutton的代碼仍然那張if(AMRadioButton.Checked = true)
裏面是不是我想要的着,當然,當我打勾LMradiobutton在這裏沒有在amradiobutton.Checked應該是else if (LMRadioButton.Checked = true)
的代碼。
做我錯過了什麼?請幫助
似乎兩個單選按鈕觸發不同的事件(AMRadioButton_CheckedChanged和LMRadioButton_CheckedChanged)。你檢查過這些事件嗎?這裏發佈的代碼來自不同的事件處理程序(addbutton_click)。如果他們被選中 – iceheaven31
IM只是測試。 – user2705620