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

RadGrid Template content accessibility.

1 Answer 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 01 Sep 2014, 10:50 AM
Hello there.

I'm rather new to the telerik world so please bare with me.
C#, Asp.net.

Im currently having a RadGrid load my content from some DObjectDataSource.

Now i want to make my own insert template, with a asp textbox.
I've done this like so:

RadGrid > MasterTableView > Columns > GridTemplateColumn > InsertItemTemplate.

Within the InsertItemTemplate i have created a asp textbox:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

From my codebehind id like to be able to acess this to set it's value and later pull the value and save it to the database.

Is anyone able to make me a working example of getting the contents of a asp textbox from within the InsertItemTemplate? 
It would be much appriciated.

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 01 Sep 2014, 04:11 PM
Hello,

I have already answered your support ticket opened on the matter:

If you have for example a TextBox control inside InsertItemTemplate you can use the code snippet below to access it:
Copy Code
<telerik:GridTemplateColumn HeaderText="Column1">
    <InsertItemTemplate>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </InsertItemTemplate>
</telerik:GridTemplateColumn>

Copy Code
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)
    {
      GridEditFormInsertItem edit = (GridEditFormInsertItem)e.Item;
      TextBox txt = (TextBox)edit.FindControl("TextBox1"); // Access the Textbox Control        
    }
}

Give it a try and let me know if you need additional assistance.


In order to avoid duplicate posts I will ask you to continue our communication there.

Regards,
Pavlina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or