Asp.net 如何实现单选按钮列表上的if语句?
我有一个电子商务网站,在我的订单页面,我有3个单选按钮列表,即:现金支付,支付网关和银行存款。我计划做的是,当你选择现金支付时,它将引导你进入现金支付页面,当你进入支付网关时,它将引导你进入另一个页面,依此类推 我知道它的代码:Asp.net 如何实现单选按钮列表上的if语句?,asp.net,radiobuttonlist,Asp.net,Radiobuttonlist,我有一个电子商务网站,在我的订单页面,我有3个单选按钮列表,即:现金支付,支付网关和银行存款。我计划做的是,当你选择现金支付时,它将引导你进入现金支付页面,当你进入支付网关时,它将引导你进入另一个页面,依此类推 我知道它的代码: if (rblPaymentMethod.SelectedItem.Value="1") { code here: } 但是有了这些代码,我不知道应该把它放在哪里 protected void btnPlaceOrder_Click(object sender, Ev
if
(rblPaymentMethod.SelectedItem.Value="1")
{
code here:
}
但是有了这些代码,我不知道应该把它放在哪里
protected void btnPlaceOrder_Click(object sender, EventArgs e)
{
string productids = string.Empty;
DataTable dt;
if (Session["MyCart"] != null)
{
dt = (DataTable)Session["MyCart"];
decimal totalPrice, totalProducts;
bool totalPriceConversionResult = decimal.TryParse(txtTotalPrice.Text, out totalPrice), totalProductsConversionResult = decimal.TryParse(txtTotalProducts.Text, out totalProducts);
ShoppingCart k = new ShoppingCart()
{
CustomerName = txtCustomerName.Text,
CustomerEmailID = txtCustomerEmailID.Text,
CustomerAddress = txtCustomerAddress.Text,
CustomerPhoneNo = txtCustomerPhoneNo.Text,
TotalProducts = totalProductsConversionResult ? Convert.ToInt32(totalProducts) : 0,
TotalPrice = totalPriceConversionResult ? Convert.ToInt32(totalPrice) : 0,
ProductList = productids,
PaymentMethod = rblPaymentMethod.SelectedItem.Text
};
DataTable dtResult = k.SaveCustomerDetails();
for (int i = 0; i < dt.Rows.Count; i++) // loop on how many products are added by the user
{
ShoppingCart SaveProducts = new ShoppingCart()
{
CustomerID = Convert.ToInt32(dtResult.Rows[0][0]),
ProductID = Convert.ToInt32(dt.Rows[i]["ProductID"]),
TotalProducts = Convert.ToInt32(dt.Rows[i]["ProductQuantity"]),
};
SaveProducts.SaveCustomerProducts();
}
lblTransactionNo.Text = "Your Transaction Number: " + dtResult.Rows[0][0];
pnlOrderPlaceSuccessfully.Visible = true;
pnlCheckOut.Visible = false;
pnlCategories.Visible = false;
pnlMyCart.Visible = false;
pnlEmptyCart.Visible = false;
pnlProducts.Visible = false;
SendOrderPlacedAlert(txtCustomerName.Text, txtCustomerEmailID.Text, Convert.ToString(dtResult.Rows[0][0]));
}
}
protectedvoid btnPlaceOrder\u单击(对象发送者,事件参数e)
{
string productids=string.Empty;
数据表dt;
如果(会话[“MyCart”]!=null)
{
dt=(数据表)会话[“MyCart”];
十进制总价格,总产品;
bool totalPrice conversionresult=decimal.TryParse(txtotalprice.Text,out totalPrice),totalProducts conversionresult=decimal.TryParse(txtotalproducts.Text,out totalProducts);
ShoppingCart k=新的ShoppingCart()
{
CustomerName=txtCustomerName.Text,
CustomerEmailID=txtCustomerEmailID.Text,
CustomerAddress=txtCustomerAddress.Text,
CustomerPhoneNo=txtCustomerPhoneNo.Text,
TotalProducts=totalProductsConversionResult?Convert.ToInt32(TotalProducts):0,
TotalPrice=totalPriceConversionResult?Convert.ToInt32(TotalPrice):0,
ProductList=productId,
PaymentMethod=rblPaymentMethod.SelectedItem.Text
};
DataTable dtResult=k.SaveCustomerDetails();
for(int i=0;i
任何想法都将不胜感激。谢谢 循环浏览列表项,然后添加if语句 这里有一个代码示例
protected void Button1_Click(object sender, EventArgs e)
{
foreach (ListItem li in RadioButtonList1.Items)
{
if (li.Selected)
{
Label1.Text = RadioButtonList1.SelectedValue ;
}
}
}
希望它能帮助你,别忘了接受我最好的答案:)