This is a migrated thread and some comments may be shown as answers.

Binding to a textbox within a RadPanelBar on a Radgrid edit form

1 Answer 115 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 25 Jan 2011, 04:54 PM
I have a grid with an edit form that has a radpanelbar implemented.  When I go into edit mode, I am trying to set the data in a textbox to its proper value.

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

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 28 Jan 2011, 11:25 AM
Hi Steve,

Can you specify how is the grid bound? You can try debugging to see what is the actual type of the e.Item.DataItem object.

Greetings,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or