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

acces a field in a web user control

2 Answers 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 18 Aug 2011, 07:19 PM
Hi,

I'm presently working on a application that use a radGrid with a Web User Control, so I used this demo to help me. I also want, in my Web User Control, to have a button that will make appears a window that will return a value that will fill a field (tbField) inside the Web User Control (like in this demo). So I tried it out, but I wasn't able to realise my scenario. Here is the problem : the javaScript code for calling the window and get back the value is write in the page that containt the radGrid. I'm able to get the value from the window, but I don't know how to set it to the field in the Web User Control (tbField). Here is my code in js function : 

// Function that is called from the window to "get back" the value and fill the field tbField
function test(args) {
    RadAjaxManager1.ajaxRequest(args);
}

So, how do I access the field in the Web User Control from code-behind. Guess it should be something like
"row that is edited".FindControl("tbField") as TextBox

 but I don't know how to get the edited row.

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 19 Aug 2011, 05:35 AM
Hello David,

Try the following code snippet to access TextBox in UserControl.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
  {
        GridEditFormItem item = (GridEditFormItem)e.Item;
        UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
        TextBox txt1 = (TextBox)userControl.FindControl("tbField");
  }
}

Thanks,
Princy.
0
David
Top achievements
Rank 1
answered on 19 Aug 2011, 02:30 PM
Thank you
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
David
Top achievements
Rank 1
Share this question
or