I have textbox code in .aspx file as below
<telerik:GridTemplateColumn UniqueName="Format" HeaderText="Format" DataField="SystemMessageTextId" HeaderStyle-Width="60">
<ItemTemplate>
<asp:Label runat="server" ID="lblFormat" Text='<%# Eval("Format") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtFormat" Text='<%# Bind("Format") %>' MaxLength="255"></asp:TextBox>
<span style="color: Red">*
<asp:RequiredFieldValidator ID="rfFormat" runat="server" ErrorMessage = "Please enter a valid Format value." ControlToValidate="txtFormat" Display="Dynamic"></asp:RequiredFieldValidator>
</span>
</EditItemTemplate>
</telerik:GridTemplateColumn>
The .aspx.cs file looks like below
if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode))
{
GridEditableItem edititem = (GridEditableItem)e.Item;
((TextBox)(edititem["Format"].FindControl("txtFormat"))).Text = "pdf";
}
I have this part in GridItemCreated function, but when I try it, the default value won’t show. Can someone help me with this?
Thanks
Please try with the below code snippet.
If you want to assign/access data then its better to use ItemDataBound event.
Suppose you want assign textchanged event to Textbox then if we have to use ItemCreated event.