XXX对象无法强制转换成“System.Data.DataRowView”2天了还没解决
在3层结构中我定义了2个类
实体类
[Serializable]
public class CartItemInfo
{
private string name;
/// <summary>
/// 构造方法,初始化商品的各个属性
/// </summary>
/// <param name= "name "> 名称 </param>
public CartItemInfo(string name)
{
this.name = name;
}
public string Name
{
get { return name; }
}
业务类
[Serializable]
public class Cart
{
private Dictionary <string, CartItemInfo> cartItems = new Dictionary <string, CartItemInfo> ();
public ICollection <CartItemInfo> CartItems
{
get { return cartItems.Values; }
}
用户层里面的Repeater控件的数据绑定方法为
private void BindCart()
{
ICollection <CartItemInfo> cart = Cart.CartItems;
if (cart.Count > 0)
{
repShoppingCart.DataSource = cart;
repShoppingCart.DataBind();
PrintTotal();
//plhTotal.Visible = true;
}
}
现在的问题是我要在Repeater的OnItemDataBound事件中执行转换就提示CartItemInfo对象不能强制转换为“System.Data.DataRowView”
protected void repShoppingCart_OnItemDataBound(object source,RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemTy