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

How to find div control in edit form server side

1 Answer 687 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shira
Top achievements
Rank 1
Shira asked on 31 May 2011, 10:28 PM
I have a RadGrid with an EditForm (defined declaratively in an EditFormSettings-FormTemplate).  In that template, I set up a table with one row for each field I'm allowing the user to edit.  One of those rows needs to be selectively disabled server side from code behind.  I'm trying to do that in the ItemDataBound method.  I use the FindControl method on the GridItem passed into that method (parameter

GridItemEventArgs

 

 

e, property Item, if it's a GridEditFormItem).  If I try to find the label or textbox control that I want to disable, I can find them and set their visibility fine.  But if I try giving an Id to the Tr table row tag, or to a div that I wrap around that tag, and try FindControl with the id of those controls, item.FindControl does not find the control.  I want to disable the entire table row, not just the controls in that row.  How can I do that?

Thanks!

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Vasil
Telerik team
answered on 01 Jun 2011, 11:14 AM
Hi Shira,

Try to set runat="server" property for the table in order to make the table server control and access it in the code-behind. Here is an example how to hide the first row in the sample table.

Aspx:
<table runat="server" id="Table1">
  <tr id="Tr1">
    <td>
      some text in first row
    </td>
  </tr>
        <tr id="Tr2">
    <td>
      some text in second row
    </td>
  </tr>
</table>
C#:
item.FindControl("Table1").FindControl("Tr1").Visible = false;

I hope this helps.

Best wishes,
Vasil
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
Shira
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or