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

How can i get the value of controls inside the data template , i placed data template outside of Rad Data form ,When inset or update or delete button click how can i get the value of controls ?

4 Answers 243 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
GaneshBabu
Top achievements
Rank 1
GaneshBabu asked on 01 Mar 2012, 12:40 PM

<navigation:Page x:Class="ABIRSMIGRATION.Views.SellerStatic"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="695" d:DesignHeight="400"
           Title="SellerStatic Page" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
    <Grid x:Name="LayoutRoot" Height="500">
        <Grid.Resources>
            <DataTemplate x:Key="MyTemplate">
                <Grid>
                    <TextBlock Height="23" HorizontalAlignment="Left" Margin="1,37,0,0" Name="txtBlock" Text="Seller Identifier :" VerticalAlignment="Top" Width="100" />
                    <!--<telerik:DataFormDataField Grid.RowSpan="2" Height="50" HorizontalAlignment="Left" Margin="55,12,0,0" Name="dftSellerIdentifier"   DataMemberBinding="{Binding seller_id, Mode=TwoWay}" VerticalAlignment="Top" Width="197"  />-->
                    <TextBox Height="23" HorizontalAlignment="Left" Margin="118,37,0,0" Name="txtSellerIdentifier" VerticalAlignment="Top" Width="85" Grid.RowSpan="2" Text="{Binding seller_id, Mode=TwoWay}" />

 </Grid>
            </DataTemplate>

        </Grid.Resources>
        <telerik:RadDataForm x:Name="radSellerDataForm"
                           AutoGenerateFields="False"
                           ReadOnlyTemplate="{StaticResource MyTemplate}"
                            NewItemTemplate="{StaticResource MyTemplate}" EditTemplate="{StaticResource MyTemplate}" AutoEdit="True" CommandButtonsVisibility="Navigation" Margin="4,49,15,1">
                           
        </telerik:RadDataForm>

        <telerik:RadButton Content="INSERT" Height="Auto" HorizontalAlignment="Left" Margin="120,10,0,0" Name="btnInsert" VerticalAlignment="Top" Width="75" FontWeight="Bold" Click="btnInsert_Click" />
        <telerik:RadButton Content="DELETE" Height="Auto" HorizontalAlignment="Left" Margin="220,10,0,0" Name="btnDelete" VerticalAlignment="Top" Width="75" FontWeight="Bold" />
        <telerik:RadButton Content="UPDATE" Height="Auto" HorizontalAlignment="Left" Margin="320,10,0,0" Name="btnUpdate" VerticalAlignment="Top" Width="75" FontWeight="Bold" Click="btnUpdate_Click" />
        <!--<telerik:RadButton Content=">>" Height="Auto" HorizontalAlignment="Left" Margin="129,92,0,0" Name="btnNext" VerticalAlignment="Top" Width="55" />
        <telerik:RadButton Content="&lt;&lt;" Height="Auto" HorizontalAlignment="Left" Margin="40,92,0,0" Name="btnPrev" VerticalAlignment="Top" Width="55" />-->
        <telerik:RadButton Content="EXIT" Height="Auto" HorizontalAlignment="Left" Margin="420,10,0,0" Name="btnExit" VerticalAlignment="Top" Width="75" FontWeight="Bold" />

    </Grid>
</navigation:Page>

reference :http://www.telerik.com/help/silverlight/raddataform-customized-fields.html

4 Answers, 1 is accepted

Sort by
0
Amitkumar
Top achievements
Rank 1
answered on 02 Jul 2012, 01:44 PM
Did you find any solution for this i have same issue.
0
vk
Top achievements
Rank 1
answered on 02 Jul 2012, 06:35 PM
var textBox = radSellerDataForm.ChildrenOfType<TextBox>()
     .Where(c=>c.Name == "txtSellerIdentifier").SingleOrDefault();
if(textBox != null)
{
     string value = textBox.Text;
}

0
Amitkumar
Top achievements
Rank 1
answered on 03 Jul 2012, 07:38 AM
Thank you,
You are genius.
Can you tell me How can we handle cancel button programmatically?
I tried with 
   MyRadDataForm.CancelEdit();
But it is not working?
do you have any solution?


0
Almond
Top achievements
Rank 1
answered on 10 Sep 2012, 11:45 PM
Good am Amitkumar,

What do you want to do with the cancel button programmatically?

The cancel button event can actually be captured at the EditEnding event of the RadDataForm please see code below:

private void myRadDataForm_EditEnding(object sender, Telerik.Windows.Controls.Data.DataForm.EditEndingEventArgs e)
        {
            if (e.EditAction == Telerik.Windows.Controls.Data.DataForm.EditAction.Commit)  //for the OK Button
            {
             .....           
            }
            else if (e.EditAction == Telerik.Windows.Controls.Data.DataForm.EditAction.Cancel) //for the Cancel Button
            {
             .....
            }
       }

Then do the commit changes in the EditEnding event of the RadDataForm like the code below:
private void myRadDataForm__EditEnded(object sender, Telerik.Windows.Controls.Data.DataForm.EditEndingEventArgs e)
        {
            if (e.EditAction == Telerik.Windows.Controls.Data.DataForm.EditAction.Commit)  //for the OK Button
            {
             .....           
             myDomainContext _DomainContext = (myDomainContext)(myDS.DomainContext);
             this.myDS.SubmitChanges();            
            }
            else if (e.EditAction == Telerik.Windows.Controls.Data.DataForm.EditAction.Cancel) //for the Cancel Button
            {
             .....
            myRadDataForm.CancelEdit();
            }
       }

hope the above code gave you some idea with your inquiry.

Thanks :)
Tags
DataForm
Asked by
GaneshBabu
Top achievements
Rank 1
Answers by
Amitkumar
Top achievements
Rank 1
vk
Top achievements
Rank 1
Almond
Top achievements
Rank 1
Share this question
or