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

Filling EditItemTemplate...

2 Answers 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Milan Gurung
Top achievements
Rank 1
Milan Gurung asked on 05 Jan 2009, 06:23 PM
Hi,

Can someone please help me to figure out to fill the form fields when the user clicks on edit button.  The grid is bound to the datasource as follows:

<Columns>
                   <telerik:GridBoundColumn DataField="InvoiceDetailID">
                   </telerik:GridBoundColumn>
                   <telerik:GridTemplateColumn DataField="ItemDescription" HeaderText="Description" UniqueName="Description">
                        <ItemTemplate>
                            <asp:Label ID="lblDescription" runat="server" Text='<%# Bind("ItemDescription") %>'>' </asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox TextMode ="MultiLine" ID="txtDescription" runat="server" Height="80px" Width="200px"></asp:TextBox>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>


How do I fill txtDescription  with existing value when user clicks on Edit? I was assuming it will be field automatically but that's not the case.

Any help is highly appreciated.

Thanks.
Milan G

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 05 Jan 2009, 06:32 PM
Hello Milan,

Depending on your requirements you can use one of the following suggestions:
<EditItemTemplate> 
    <asp:TextBox TextMode ="MultiLine" ID="txtDescription" runat="server" Text='<%# Bind("ItemDescription") %>' Height="80px" Width="200px"></asp:TextBox> 
</EditItemTemplate> 

or
protected void radGrid_ItemDataBound(object sender, GridItemEventArgs e) 
    if (e.Item.IsInEditMode) 
        (e.Item.FindControl("txtDescription"as TextBox).Text = "myText"

Let us know if you need more information.

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Milan Gurung
Top achievements
Rank 1
answered on 06 Jan 2009, 08:42 AM
Thanks a lot, Daniel!

Milan G
Tags
Grid
Asked by
Milan Gurung
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Milan Gurung
Top achievements
Rank 1
Share this question
or