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

How can I access to a control exists in a EditItemTemplate from a custom event handler ?

2 Answers 159 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Homam
Top achievements
Rank 1
Homam asked on 10 Jan 2011, 09:39 AM
Hi,

I want to set a value in a control exists in a GridTemplateColumn, I've read many threads here about it and I figure out that  I must use ItemDataBound event instead,
but actually I can't, because I have a control shows a popup and the popup returns a value by a callback in the server,
so how can I deal with this situation?

The code:

protected void MyCustomControl_ItemSelected(string returnedValue)
{
    var control = (RadGrid1.EditItems[0] as GridEdittableItem).FindControl("MyCustomTextBox");
 
    if (control != null)
    {
       control.Text = returnedValue;
    }
}

Thanks in advance.


2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Jan 2011, 11:17 AM
Hello Homam,

Try the following approach to access the TextBox control in edit form.

C#:
protected void MyCustomControl_ItemSelected(string returnedValue)
   {
      int rowindex =Convert.ToInt32(RadGrid1.EditIndexes[0]);
          GridEditFormItem editItem = (GridEditFormItem)RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem)[rowindex];
          TextBox control = (TextBox)editItem.FindControl("MyCustomTextBox");
          if (control != null)
       {
          control.Text = returnedValue;
       }
   }

Thanks,
Princy.
0
Homam
Top achievements
Rank 1
answered on 10 Jan 2011, 11:46 AM
Thanks Princy for the replay,

It works well and I accessed to the control, but the set of the value didn't work, and it still remains the original value !!!

Any idea !!

Thanks in advance.
Tags
Grid
Asked by
Homam
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Homam
Top achievements
Rank 1
Share this question
or