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 ?

5 posts, 0 answers
  1. GaneshBabu
    GaneshBabu avatar
    7 posts
    Member since:
    Oct 2011

    Posted 01 Mar 2012 Link to this post

    <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

  2. Amitkumar
    Amitkumar avatar
    66 posts
    Member since:
    Aug 2009

    Posted 02 Jul 2012 Link to this post

    Did you find any solution for this i have same issue.
  3. DevCraft banner
  4. vk
    vk avatar
    46 posts
    Member since:
    Jul 2012

    Posted 02 Jul 2012 Link to this post

    var textBox = radSellerDataForm.ChildrenOfType<TextBox>()
         .Where(c=>c.Name == "txtSellerIdentifier").SingleOrDefault();
    if(textBox != null)
    {
         string value = textBox.Text;
    }

  5. Amitkumar
    Amitkumar avatar
    66 posts
    Member since:
    Aug 2009

    Posted 03 Jul 2012 Link to this post

    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?


  6. Almond
    Almond avatar
    43 posts
    Member since:
    Feb 2011

    Posted 10 Sep 2012 Link to this post

    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 :)
Back to Top
DevCraft banner