我有一个单选按钮
<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 时,代码应该else if (LMRadioButton.Checked = true)
在 amradiobutton.Checked 中没有。
我想念什么吗?请帮忙