M
Martin Høst Normark
Hi everyone
I get a System.NullReferenceException performing this code:
public void Item_Bound(object sender, DataListItemEventArgs e)
{
if((int)(e.Item.DataItem as DataRowView).Row[11] != 0)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
int aktuelt_a_id = (int)(e.Item.DataItem as DataRowView).Row[11];
if(aktuelt_a_id != temp_a_id)
{
temp_a_id = aktuelt_a_id;
Literal myL = (Literal)e.Item.FindControl("myLiteral");
myL.Text = "<h2>" + aktuelt_a_id + "</h2>";
}
}
}
else
;
}
Even this little opertion throws a InvalidCastExcepion
Double Price =
Convert.ToDouble(((DataRowView)(e.Item.DataItem)).Row.ItemArray[3].ToString());
What might be wrong?
I get a System.NullReferenceException performing this code:
public void Item_Bound(object sender, DataListItemEventArgs e)
{
if((int)(e.Item.DataItem as DataRowView).Row[11] != 0)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
int aktuelt_a_id = (int)(e.Item.DataItem as DataRowView).Row[11];
if(aktuelt_a_id != temp_a_id)
{
temp_a_id = aktuelt_a_id;
Literal myL = (Literal)e.Item.FindControl("myLiteral");
myL.Text = "<h2>" + aktuelt_a_id + "</h2>";
}
}
}
else
;
}
Even this little opertion throws a InvalidCastExcepion
Double Price =
Convert.ToDouble(((DataRowView)(e.Item.DataItem)).Row.ItemArray[3].ToString());
What might be wrong?