Hello.
I have rad grid with templated columns (readonly and edit modes).
I set programmatically some row to edit mode base on my data on ItemDataBound event handler and then try to access control from row by its Id. I can't find control from EditTemplate but exist only from ItemTemplate
I explain on simple example. Here is a grid with templated column
ItemTemplate contains Literal control with Id = WelderRd and EditItemTemplate contains control WelderEdit
Here I set one of rows to edit mode when I get data from database.
How can I get controls from EditItemTemplate after setting row to edit mode programmatically?
I have rad grid with templated columns (readonly and edit modes).
I set programmatically some row to edit mode base on my data on ItemDataBound event handler and then try to access control from row by its Id. I can't find control from EditTemplate but exist only from ItemTemplate
I explain on simple example. Here is a grid with templated column
| <telerik:RadGrid runat="server" ID="weldsGrid" AllowPaging="True" AllowSorting="True" |
| PageSize="20" GridLines="None"> |
| <MasterTableView AllowMultiColumnSorting="True" AutoGenerateColumns="False" EditMode="InPlace"> |
| <Columns> |
| <telerik:GridTemplateColumn DataField="Welder" HeaderText="Welder" |
| SortExpression="Welder" UniqueName="Welder"> |
| <EditItemTemplate> |
| <asp:TextBox ID="WelderEdit" runat="server" Text='<%# Bind("Welder")%>' |
| ontextchanged="WelderTextBox_TextChanged" AutoPostBack="True" /> |
| </EditItemTemplate> |
| <ItemTemplate> |
| <asp:Literal ID="WelderRd" runat="server" Text='<%# Eval("Welder") %>' /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| </Columns> |
| </MasterTableView> |
| <ClientSettings> |
| <Selecting AllowRowSelect="True" /> |
| </ClientSettings> |
| </telerik:RadGrid> |
Here I set one of rows to edit mode when I get data from database.
| Private Sub weldsGrid_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles weldsGrid.ItemDataBound |
| If (e.Item.ItemType = Telerik.Web.UI.GridItemType.Item OrElse _ |
| e.Item.ItemType = Telerik.Web.UI.GridItemType.AlternatingItem) Then |
| If (e.Item.ItemIndex > -1) Then |
| Dim row = CType(CType(e.Item.DataItem, DataRowView).Row, DSBiasStep.BiasWeldRow) |
| SetControlsVisibility(e.Item, row) |
| End If |
| End If |
| End Sub |
| Private Sub SetControlsVisibility(ByVal row As GridItem, ByVal data As DSBiasStep.BiasWeldRow) |
| 'set row to edit mode |
| row.Edit = data.IsActive |
| If Not data.IsIsAcceptedNull Then |
| 'even row in edit mode next row returns null |
| Dim WelderControl= TryCast(row.FindControl("WelderEdit"), TextBox) |
| If WelderControl Is Nothing Then |
| ''''There is no reason to this but this is just example. |
| 'We always find a literal control even row is in edit mode |
| WelderControl = TryCast(row.FindControl("WelderRd"), Literal) |
| End If |
| WelderControl.Enabled = CurrentUser.HasEditorRole |
| End If |
| End Sub |
How can I get controls from EditItemTemplate after setting row to edit mode programmatically?