Hi,
I am trying to change the property of a edititemtemplate's textbox control in the ItemCommand event to make certain textboxes readonly when the user wants to insert a record. Here's the template column-
Here's the snippet for the itemCommand, IGNORE the GridBoundColumn statements - I change from a GridBoundColumn to a templateColumn to allow for a validator.
Thanks in advance!
Gary
I am trying to change the property of a edititemtemplate's textbox control in the ItemCommand event to make certain textboxes readonly when the user wants to insert a record. Here's the template column-
<telerik:GridTemplateColumn HeaderText="Cage Code" SortExpression="CageCode" UniqueName="CageCodeTemplate" > |
<ItemTemplate> |
<asp:Label runat="server" ID="lblCageCode" Text='<%# Eval("CageCode") %>' /> |
</ItemTemplate> |
<EditItemTemplate > |
<asp:TextBox runat="server" CausesValidation="true" ID="tbCageCode" Text='<%# Bind("CageCode") %>' /> |
<span style="color: Red">*</span><asp:RequiredFieldValidator ID="rvalCageCode" ControlToValidate="tbCageCode" |
ErrorMessage="Required Field!" runat="server"></asp:RequiredFieldValidator> |
</EditItemTemplate> |
</telerik:GridTemplateColumn> |
Here's the snippet for the itemCommand, IGNORE the GridBoundColumn statements - I change from a GridBoundColumn to a templateColumn to allow for a validator.
protected void RadGridCageCodeLookup_ItemCommand(object source, GridCommandEventArgs e) |
{ |
//objectDatasource is stateless, must change the selectMethod to manufacturer code and add parameter of static mfg id. |
if (e.CommandName.Contains("Insert")) |
{ |
//FOR INSERTS, make cage code writable since the user is adding a CAGE code |
//FOR insert, hide manufacturer id b/c they are in the manufacturer entity-can not change |
((GridBoundColumn)RadGridCageCode.Columns.FindByUniqueName("ManufacturerID")).ReadOnly = true; |
((GridBoundColumn)RadGridCageCode.Columns.FindByUniqueName("ManufacturerID")).Visible = false; |
} |
} |
Thanks in advance!
Gary