OnCommand 이벤트에 문제가 있습니다. 이 매개 변수를 인수로 사용하거나 모든 것을 표시 할 때 CommandArgument로 사용하면 InvalidCastException이 발생합니다. 나는이ImageButton 컨트롤의 OnCommand 이벤트
public string GetIsCandidateFavoriteImageUrl(bool isNowFavorite)
{
if (isNowFavorite)
{
return @"~/_images/icon_grid_fav.gif";
}
return @"~/_images/icon_grid_unfav.gif";
}
protected void imBtnFavorite_Command(object sender, CommandEventArgs e)
{
bool isFavorite =(bool) e.CommandArgument;
}
이 있습니다. 그래서, 당신은'(bool) e.CommandArgument'에 의해 그것을 캐스팅 할 수 없습니다. –