我有2天的最佳时间试图找出如何“互相排列2次下拉列表”并将其显示在标签中......
就像在数学时多了2个数字..
plzz帮助我...
欢迎所有建议
Protected void Button1_Click(object sender, EventArgs e)
{
int amount1 = int.parse(DropDownList1.selectedValue.ToString());
int amount2 = int.parse(DropDownList1.selectedValue.ToString());
Label.Text = amount1 * amount2;
}
我收到错误:
无法将类型'Int'隐式转换为'string
答案 0 :(得分:4)
只需使用:
Label.Text = (amount1 * amount2).ToString();
因为您无法将整数结果分配给字符串Label.Text属性。
答案 1 :(得分:0)
你也可以这样做
int val = amount1 * amount2;
Label.Text = val.ToString();
Label.Text
期望String并且您尝试为其分配整数。