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

[Solved] Get Reference to the UserControl Within the Grid

1 Answer 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Arlyne
Top achievements
Rank 1
Arlyne asked on 14 Sep 2009, 01:15 PM
Hi All,

Is there a way to get the usercontrol within the radgrid on client side? I have searched everywhere and i can't find a way to do it.

Here is the scenario, I have a Radgrid with WebUserControl as the EditMode. Within the usercontrol I call a popup with dropdown on it where the user will be able to select some data. The data that was selected from the popup should be passed to the Editfrom User control Textbox.

I tried using radwindow but it still cannot find the usercontrol. I really need suggestions.

Thank you so much.

1 Answer, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 17 Sep 2009, 08:51 AM
Hi Arlyne,

I recommend that you achieve the desired functionality registering for the client-side script for updating the texttbox with the dropdown selected value on ItemCreated/ItemDataBound event. You could do this in the following way:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode) 
        { 
            GridEditFormItem item = (GridEditFormItem)e.Item; 
            (item.FindControl("DropDownList1"as DropDownList).Attributes.Add("onchange", String.Format("updateTextbox('{0}','{1}');", item.FindControl("TextBox1").ClientID, item.FindControl("DropDownList1").ClientID)); 
        } 
    } 

Then to set the value of the textbox in Javascript try the below code:
       function updateTextbox(txtBox, ddList) { 
 
            var textBox = $get(txtBox); 
            var dropDown = $get(ddList); 
            textBox.value = dropDown.value; 
 
        } 

I am also attaching a sample project showing how it is done.

Kind regards,
Mira
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Arlyne
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or