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

Bind Template column code behind

0 Answers 98 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chirag
Top achievements
Rank 1
Chirag asked on 26 May 2012, 09:09 AM
hi to all 
i have one telerik radgridvie and one source 
in source their is a one BYTE[] 

<UserControl.Resources>
  <DataTemplate x:Key="FileDownloadTemplate">
            <Border BorderBrush="Red" BorderThickness="2" Margin="2" Height="50">
                <TextBlock x:Name="FileName" Text="" ></TextBlock>
            </Border>
        </DataTemplate>
    </UserControl.Resources>
 
 <StackPanel x:Name="StkGrid" Orientation="Vertical" >
                        <telerik:RadGridView x:Name="FormsGrid"  CanUserFreezeColumns="False" MinHeight="25"  SelectionMode="Single" 
                                              AutoGenerateColumns="False"   ScrollMode="RealTime" 
                                              BorderThickness="1,6,1,1" telerik:StyleManager.Theme="Office_Blue"
                                              ScrollViewer.HorizontalScrollBarVisibility="Visible"                                                 
                                              ScrollViewer.VerticalScrollBarVisibility="Auto"  ShowGroupPanel="True" SelectionChanged="FormsGrid_SelectionChanged"                                              
                                              CanUserDeleteRows="False" CanUserInsertRows="False" Sorting="FormsGrid_Sorting" Grouped="FormsGrid_Grouped">
                        </telerik:RadGridView>
                        <telerik:RadDataPager x:Name="radDataPager1" telerik:StyleManager.Theme="Office_Blue" Template="{StaticResource RadDataPagerTemplate}"
                                   PageSize="{Binding Path=DataPagerPageSize, Mode=TwoWay}"
                                   DisplayMode="All"  NumericButtonCount="10"                                
                                   IsTotalItemCountFixed="True"
                                   PageIndexChanging="radDataPager1_PageIndexChanging" />
                    </StackPanel>

foreach (KeyValuePair<string, string> kvp in SLColumnDefination)
    Fc = new FilterControl();
    Fc.FilterCriteriaList = FilterCriteriaList;
    Fc.Filter += new EventHandler(Fc_Filter);
    Fc.ClearFilter += new EventHandler(Fc_ClearFilter);
  
    if (FilterCriteriaList != null && FilterCriteriaList.Count > 0)
    {
        Fc.IsActive = (FilterCriteriaList.Keys.ToArray().Contains(kvp.Key)) ? FilterCriteriaList[kvp.Key].IsActive : false;
    }
  
    dgtc = new GridViewDataColumn();
    dgtc.MinWidth = 100;
    dgtc.IsReadOnly = true;
    dgtc.Width = GridViewLength.SizeToHeader;
  
    dgtc.Header = kvp.Key.ToString();
    if (kvp.Value.ToLower() == "byte[]")
    {
        EntityViewConverter Value_Converter = new EntityViewConverter();
        Binding bind = new Binding
        {
            Converter = Value_Converter,
            Mode = BindingMode.TwoWay,
            Path = new System.Windows.PropertyPath(kvp.Key),                             
        };
        dgtc.CellTemplate = this.Resources["FileDownloadTemplate"] as DataTemplate;                          
        dgtc.DataMemberBinding = bind;
    }
    else
    {
        dgtc.DataMemberBinding = new Binding(kvp.Key);
    }
    dgtc.DataMemberBinding.Source = kvp.Key;
  
    dgtc.FilteringControl = Fc;
  
    FormsGrid.Columns.Add(dgtc);
     
}


class EntityViewConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string strunicode = (new System.Text.UnicodeEncoding()).GetString((value as byte[]), 0, (value as byte[]).Length);
            return strunicode;
        }
  
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }


Now My problem is how to bind My template's textblock with converted Text 
also when i am click on that textblock one event will be call and return a full row data  like (grid.selectedrow)
it's a grate help if you can post a sample 
Tags
GridView
Asked by
Chirag
Top achievements
Rank 1
Share this question
or