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

findcontrol control in insert mode

1 Answer 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
pradeep k
Top achievements
Rank 1
pradeep k asked on 29 Jul 2010, 08:24 PM
Hi,
   how can i found the control in insert mode .please help me regarding this.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Jul 2010, 05:11 AM
Hello Pradeep,

You can try the following code snippet to access the control in insert mode.

ASPX:
<telerik:GridBoundColumn UniqueName="GridBoundColumn1" DataField="EmployeeID" HeaderText="EmployeeID">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn>
  <EditItemTemplate>
     <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
  </EditItemTemplate>
</telerik:GridTemplateColumn>

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
   if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)//if EditMode is 'EditForms' or 'PopUp'
        {
            GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
            TextBox txt = (TextBox)insertItem["GridBoundColumn1"].Controls[0];//accessing control in GridBoundColumn
            TextBox txt2 = (TextBox)insertItem.FindControl("TextBox1");//accessing control in GridTemplateColumn
 
        }
 if (e.Item.OwnerTableView.IsItemInserted && e.Item is GridDataInsertItem)//if EditMode is 'InPlace'
        {
            GridDataInsertItem insertItem = (GridDataInsertItem)e.Item;
            TextBox txt = (TextBox)insertItem["GridBoundColumn1"].Controls[0];
            TextBox txt2 = (TextBox)insertItem.FindControl("TextBox1");
        }
     }

Thanks,
Princy.
Tags
Grid
Asked by
pradeep k
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or