Here is the code I am using (found this while searching):
protected void EmpGrid_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
{
GridEditFormItem gditem = e.Item as GridEditFormItem;
RadPanelBar RadPanelBar1 = gditem.FindControl("RadPanelBar1") as RadPanelBar;
RadPanelItem panelItem1 = (RadPanelItem)RadPanelBar1.FindItemByText("Forwarding Info");
TextBox txtForwardCompany = panelItem1.FindControl("txtForwardCompany") as TextBox;
txtForwardCompany.Text = (gditem.DataItem as DataRowView)["EmpForwardCompany"].ToString();
}
}
The problem is that (gditem.DataItem as DataRowView) returns null. The gditem.DataItem object is populated, it apparently can't be cast to a DataRowView. Any thoughts on what I'm doing wrong here?
Thanks in advance