3

I have my own method and I am trying to findcontrol on a control inside the GridTemplateColumn, so I am doing it outside of the events for the radGrid. Is this possible and if so, how?

Thanks!

  • Do you know what row it will be in? – Roman Nov 03 '11 at 01:12
  • Before postback or after? Also, around what stage in the page lifecycle do you want to do this? – Roman Nov 03 '11 at 01:53
  • Before postback. I basically want to do it when the page loads. Thanks! –  Nov 03 '11 at 01:59
  • You'll probably have to do it from PreRender event handler, just look through the controls collection of your grid and figure out what the control tree looks like to find the control you're looking for. – Roman Nov 03 '11 at 02:42

1 Answers1

5

Try with below code.

 <telerik:GridTemplateColumn>
            <ItemTemplate>
                <asp:Label ID="Label1"></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1"></asp:TextBox>
            </EditItemTemplate>
           </telerik:GridTemplateColumn>

...................

button1_click()
{
     // for Normal mode
    foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
    {
        Label Label1 = item.FindControl("Label1") as Label;
    }

    // for edit mode
    foreach (GridDataItem item in RadGrid1.EditItems)
    {
        TextBox TextBox1 = item.FindControl("TextBox") as TextBox;
    }
}

Thanks, Jayesh Goyani

Jayesh Goyani
  • 11,008
  • 11
  • 30
  • 50
  • Hi Jayesh, can you assist on http://stackoverflow.com/questions/35417963/make-radeditor-invisible-in-radgrid – Nate Pet Feb 15 '16 at 22:04
  • Jayesh http://stackoverflow.com/questions/35436413/findcontrol-return-null-for-radeditor is the complete path – Nate Pet Feb 16 '16 at 15:28