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

Finding Control inside RadGrid FormTemplate

1 Answer 43 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
ABC
Top achievements
Rank 1
ABC asked on 18 Apr 2013, 11:00 AM

Let' say I have this grid,

<telerik:RadGrid
    ...........................
    ...........................
    <FormTemplate>
            <asp:TextBox ID="txtDescription" runat="server" />
    </FormTemplate>
    ...........................
    ...........................
    ...........................

Now In code behind I need txtDescription inside DataSource1_Updating event,

    protected void DataSource1_Updating(object sender, SqlDataSourceCommandEventArgs e){

Is this is possible?

1 Answer, 1 is accepted

Sort by
0
ABC
Top achievements
Rank 1
answered on 18 Apr 2013, 12:21 PM
Here is how I fixed this issue. Defined a EditCommand,

        protected void RadGrid1_EditCommand(object sender, GridCommandEventArgs e)
        {
            ViewState["CurrentIndex"] = e.Item.ItemIndex;
        }

and in my event,

    protected void DataSource1_Updating(object sender, SqlDataSourceCommandEventArgs e){

            var currentIndex = (int)ViewState["CurrentIndex"];
            var form = RadGrid1.Items[currentIndex].EditFormItem;
            var txtDescription= form.FindControl("txtDescription") as RadComboBox;
Tags
General Discussions
Asked by
ABC
Top achievements
Rank 1
Answers by
ABC
Top achievements
Rank 1
Share this question
or