[英]An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in user code
[英]An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in the user code
protected void btnAdd_Click(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(Request.QueryString["id"]))
{
string kundeID = Context.User.Identity.GetUserId();
if (kundeID != null)
{
int id = Convert.ToInt32(Request.QueryString["id"]);
int totalsum = Convert.ToInt32(ddlAmount.SelectedValue);
Handlevogn handlevogn = new Handlevogn
{
TotalSum = totalsum,
KundeID = short.Parse(kundeID),
Dato = DateTime.Now,
ErIHandlevogn = true,
ProduktID = id
};
HandlevognModell model = new HandlevognModell();
lblResult.Text = model.InsertHandlevogn(handlevogn);
}
else
{
lblResult.Text = "Please log in to order items";
}
mscorlib.dll中发生类型'System.FormatException'的异常,但未在用户代码中处理
尝试添加toString调用
KundeID = short.Parse(kundeID.ToString());
所以基本上变成了
Handlevogn handlevogn = new Handlevogn
{
TotalSum = totalsum,
KundeID = short.Parse(kundeID.toString()),
Dato = DateTime.Now,
ErIHandlevogn = true,
ProduktID = id
};
希望这对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.