Hi all!
I have the following code below which throws the above error
protected
void ViewStudentGrid_ItemCommand(object source, Telerik.WebControls.GridCommandEventArgs e)
{
//Get the GridDataItem of the RadGrid , the row below cause the error
GridDataItem item = (GridDataItem) e.Item;
//Get the primary key value using the DataKeyValue.
Guid gdStudId = new Guid(item.OwnerTableView.DataKeyValues[item.ItemIndex]["StudId"].ToString());
try
{
DeleteClass.DeletePeriods(gdStudId);
//ParameterManager.CourseTypeDelete(CourseID);
}
catch (Exception ex)
{
ViewStudentGrid.Controls.Add(
new LiteralControl("Unable to Delete Record. Reason: " + ex.Message));
e.Canceled =
true;
}
}
and yet in this other code below, the casting works fine.
protected
void PeriodsRadGrid_DeleteCommand(object source, Telerik.WebControls.GridCommandEventArgs e)
{
//Get the GridDataItem of the RadGrid, no error caused in line below
GridDataItem item = (GridDataItem)e.Item;
//Get the primary key value using the DataKeyValue.
Guid gdPeriodId = new Guid(item.OwnerTableView.DataKeyValues[item.ItemIndex]["PeriodId"].ToString());
try
{
DeleteClass.DeletePeriods(gdPeriodId);
//ParameterManager.CourseTypeDelete(CourseID);
}
catch (Exception ex)
{
StudyPeriodsGrid.Controls.Add(
new LiteralControl("Unable to Delete Record. Reason: " + ex.Message));
e.Canceled =
true;
}
}
What could be the difference in the casting in both cases.
Thnx so much.