无法将类型为“System.DBNull”的对象强制转换为类型“System.String”。
protectedvoidPage_Load(objectsender,EventArgse){intwareID;int.TryParse(string.IsNullO...
protected void Page_Load(object sender, EventArgs e)
{
int wareID;
int.TryParse(string.IsNullOrEmpty(Request.Params["wareID"]) ? "0" : Request.Params["wareID"], out wareID);
IStoreDBO wareDetail=new IStoreDBO();
wareDetails mywareDetails = wareDetail.GetwareDetails(wareID);
desc.Text = mywareDetails.Description;
UnitCost.Text = string.Format("{0:c}",mywareDetails.UnitCost);
ModelName.Text = mywareDetails.ModelName;
ModelNumber.Text = mywareDetails.ModelNumber;
addToCart.NavigateUrl = "AddToCart.aspx?wareID=" + wareID;
} 展开
{
int wareID;
int.TryParse(string.IsNullOrEmpty(Request.Params["wareID"]) ? "0" : Request.Params["wareID"], out wareID);
IStoreDBO wareDetail=new IStoreDBO();
wareDetails mywareDetails = wareDetail.GetwareDetails(wareID);
desc.Text = mywareDetails.Description;
UnitCost.Text = string.Format("{0:c}",mywareDetails.UnitCost);
ModelName.Text = mywareDetails.ModelName;
ModelNumber.Text = mywareDetails.ModelNumber;
addToCart.NavigateUrl = "AddToCart.aspx?wareID=" + wareID;
} 展开
2个回答
展开全部
mywareDetails.UnitCost 做个判断,为null时就不要string.Format()了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询