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

[Solved] Access Controls in Insert Form

1 Answer 144 Views
Grid
This is a migrated thread and some comments may be shown as answers.
jfkrueger
Top achievements
Rank 1
jfkrueger asked on 03 Apr 2009, 06:07 PM
Hi there,

I have a need to access a ComboBox that is inside the Edit/Insert form from the AjaxRequest method of the RadAjaxManager. I have no problem accessing the combobox if a record is being edited using the following code:

Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest  
 
        Dim RadComboBoxName As RadComboBox = Nothing           
 
        For Each myItem As GridDataItem In RadGridPpoCodes.EditItems   
 
            RadComboBoxName = TryCast(myItem.EditFormItem.FindControl("RadComboBoxName"), RadComboBox)  
 
            If Not RadComboBoxName IS Nothing Then  
 
                RadComboBoxName.DataBind()  
 
            End If  
 
        Next  
 
End Sub 

However I can't seem to figure out how to access the combobox if a record is being Inserted.

Any help?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Apr 2009, 05:28 AM
Hello Joe,

Try the following code snippet for accessing RadCombobBox if the row in insert mode.

ASPX of RadAjaxManager:
 
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">     
    <AjaxSettings>         
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">     
            <UpdatedControls>    
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" />    
            </UpdatedControls>    
        </telerik:AjaxSetting>    
    </AjaxSettings>    
</telerik:RadAjaxManager>  

VB:
 
Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As ObjectByVal e As AjaxRequestEventArgs)     
    Dim RadComboBoxName As RadComboBox = Nothing    
    If RadGrid1.MasterTableView.IsItemInserted Then    
        Dim myItem As GridDataItem = DirectCast(RadGrid1.MasterTableView.GetInsertItem(), GridDataItem)     
        If True Then    
            RadComboBoxName = TryCast(myItem.FindControl("RadComboBox1"), RadComboBox)     
            If (RadComboBoxName IsNot NothingThen    
                'RadComboBoxItem item = new RadComboBoxItem("New Item");     
                'RadComboBoxName.Items.Add(item);     
                RadComboBoxName.DataBind()     
            End If    
        End If    
    End If    
End Sub 

Thanks,
Princy.
Tags
Grid
Asked by
jfkrueger
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or