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

getting radcombo id in javascript

1 Answer 34 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ramakrishna
Top achievements
Rank 1
Ramakrishna asked on 30 Jun 2010, 01:38 PM
Have a rad combobox in  rad grid.
the combobox has got checkboxes which i need to validate .

on the click of checkbox i need to get the id of rad combo.

getting error 'this control does not exist in the current context

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 01 Jul 2010, 07:18 AM
Hello Ramakrishna,

In order to achieve this, access the RadComboBox and RadComboxItem(CheckBox placed in ItemTemplate) in Itemcreated event. Then attach 'onclick' client event to CheckBox by passing the RadComboBox's ClientID to the event handler. Check out the following code.
 
ASPX:
 
 <telerik:GridTemplateColumn> 
    <ItemTemplate> 
        <telerik:RadComboBox ID="RadComboBox1" runat="server"
            <Items> 
                <telerik:RadComboBoxItem /> 
                <telerik:RadComboBoxItem /> 
                <telerik:RadComboBoxItem /> 
            </Items> 
            <ItemTemplate> 
                <asp:CheckBox ID="CheckBox1" runat="server" /> 
            </ItemTemplate> 
        </telerik:RadComboBox> 
    </ItemTemplate> 
 </telerik:GridTemplateColumn> 

C#:
  
 protected void dgCompanyData_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            RadComboBox combo = (RadComboBox)item.FindControl("RadComboBox1"); 
            foreach (RadComboBoxItem comboItem in combo.Items) 
            { 
                CheckBox chk = (CheckBox)comboItem.FindControl("CheckBox1"); 
                chk.Attributes.Add("onclick""Click(this,'" + combo.ClientID + "');"); 
            } 
       } 
    } 

Java Script:
 
 <script language="javascript" type="text/javascript"
    function Click(chk, combo)  
     { 
        var comboBox = $find(combo); 
     }   
 </script> 

Thanks,
Princy.


Tags
Grid
Asked by
Ramakrishna
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or