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

[Solved] How to refrence items in EditForm Template

5 Answers 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
bradley baker
Top achievements
Rank 1
bradley baker asked on 27 Oct 2009, 08:11 PM
Trying to update a label in a editform template when the value of a drop down box is changed.  However it keeps telling me the labels isnt defined because its in the editform template, if I move it out of the template it works just fine.

5 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 27 Oct 2009, 09:11 PM
Hello Bradley,

Please examine the following topic:
Accessing cells and rows

if(e.Item.IsInEditMode)
{
   Label myLabel = e.Item.FindControl("Label1") as Label;
}

Regards,
Daniel
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.
0
bradley baker
Top achievements
Rank 1
answered on 27 Oct 2009, 10:19 PM
This is what I did, it will build and run but the label doesnt change.

Protected Sub RadComboBox1_SelectedIndexChanged(ByVal o As ObjectByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs)  
        Dim ClosedLab As Label = ProcReqGrid.FindControl("ClosedTimeLab")  
        If e.Value = "1" Then 
            ClosedLab.Text = "Test" 
 
        End If 
    End Sub 
0
Princy
Top achievements
Rank 2
answered on 28 Oct 2009, 10:15 AM
Hi

Try the code snippet below to access the controls in the edit form template on selected index changed of the RadCombobox in the same form. You need to access the Naming Container of the RadCombobox  which is the GridEditableItem

VB
 Private Sub RadComboBox1_SelectedIndexChanged(ByVal  sender As ObjectByVal e As  System.EventArgs) 
 
        'first reference the edited grid item through the NamingContainer attribute 
        Dim editedItem As GridEditableItem = CType(CType(sender,RadComboBox).NamingContainer,GridEditableItem) 
       
        Dim ClosedLab As Label = CType(editedItem.FindControl("ClosedTimeLab"),Label ) 
 
End Sub 


Thanks,
Princy
0
bradley baker
Top achievements
Rank 1
answered on 28 Oct 2009, 04:02 PM
Im not understanding, well I do for the most part but its not working.

If I change it go a Private then the following doesnt work because it not supported.  Though if I change it back to Protected it will compile again.
                        <telerik:RadComboBox ID="RadComboBox1" Runat="server"   
                            SelectedValue='<%# Bind("procreq_status") %>' DataSourceID="StatusSQL"   
                            DataTextField="mfgstatus_name" DataValueField="mfgstatus_id"   
                            onselectedindexchanged="RadComboBox1_SelectedIndexChanged">  
                        </telerik:RadComboBox> 

What I am trying to do is when the drop down changes from Open to Working on the label and hidden input field are updated to the current time.  Or if it changes to Closed then the closed label/hidden input field are updated to the current time.

There is no value property for editedItem.
editedItem.Value = 1 
0
bradley baker
Top achievements
Rank 1
answered on 02 Nov 2009, 04:54 PM
Anyone have ideas?
Tags
Grid
Asked by
bradley baker
Top achievements
Rank 1
Answers by
Daniel
Telerik team
bradley baker
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or