Finding Control inside RadGrid FormTemplate

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?

Upvotes: 2

Views: 2070

Answers (1)

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;

Upvotes: 1

Related Questions