Code
HistRepcolumnName.Add(ResourceFile.SrNoLevel);
HistRepcolumnName.Add(ResourceFile.RepNameLabel);Code
HistRepcolumnName.Add(ResourceFile.Date);Code
HistRepcolumnName.Add(ResourceFile.AircraftLabel);Code
HistRepcolumnName.Add(ResourceFile.Description);Code
HistRepcolumnName.Add(ResourceFile.PerDiemLabel);Code
HistRepcolumnName.Add(ResourceFile.DailyFeeLabel);Code
Binding binding = new Binding();Code
foreach (var ColumnHeader in HistRepcolumnName)Code
{C#
DataGridTemplateColumn templateColumn = new DataGridTemplateColumn(); templateColumn.Header = ColumnHeader; #region Flag 1 if (Flag == 1 || Flag == 2) { //if (Status.ToUpper() != "PAID" && Status.ToUpper() != "OPEN") // { //} //else //{ string Str = "SrNo"; if (index == 0) { Str = "SrNo"; StringBuilder CellTemp = new StringBuilder(); CellTemp.Append("); CellTemp.Append("xmlns='http://schemas.microsoft.com/winfx/"); CellTemp.Append("2006/xaml/presentation' "); CellTemp.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' "); CellTemp.Append("xmlns:local = 'clr-namespace:System.Windows.Controls"); CellTemp.Append(";assembly=System.Windows.Controls.Toolkit'>"); CellTemp.Append("); CellTemp.Append("Text ='{Binding Path=" + Str + "}' Style='{StaticResource ContentTextStyle}' IsHitTestVisible='False' "); CellTemp.Append("/>"); CellTemp.Append(""); templateColumn.CellTemplate = (DataTemplate)XamlReader.Load(CellTemp.ToString()); dgvRepAdviceList.Columns.Add(templateColumn); } else if (index == 1) { Str = "RepName"; StringBuilder CellTemp = new StringBuilder(); CellTemp.Append("); CellTemp.Append("xmlns='http://schemas.microsoft.com/winfx/"); CellTemp.Append("2006/xaml/presentation' "); CellTemp.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' "); CellTemp.Append("xmlns:local = 'clr-namespace:System.Windows.Controls"); CellTemp.Append(";assembly=System.Windows.Controls.Toolkit'>"); CellTemp.Append("); CellTemp.Append("Text ='{Binding Path=" + Str + ",Mode=TwoWay,NotifyOnValidationError=True, ValidatesOnExceptions=True}' Style='{StaticResource ContentTextStyle}' IsHitTestVisible='True' "); CellTemp.Append("Margin='4'/>"); CellTemp.Append(""); StringBuilder CellETemp = new StringBuilder(); CellETemp.Append("); CellETemp.Append("xmlns='http://schemas.microsoft.com/winfx/"); CellETemp.Append("2006/xaml/presentation' "); CellETemp.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' "); CellETemp.Append("xmlns:local = 'clr-namespace:System.Windows.Controls"); CellETemp.Append(";assembly=System.Windows.Controls.Toolkit'>"); CellETemp.Append("); CellETemp.Append("Text ='{Binding Path=" + Str + ",Mode=TwoWay,NotifyOnValidationError=True, ValidatesOnExceptions=True}' Style='{StaticResource ContentTextStyle}' IsHitTestVisible='False' "); CellETemp.Append("Margin='4'/>"); CellETemp.Append(""); templateColumn.CellTemplate = (DataTemplate)XamlReader.Load(CellTemp.ToString()); templateColumn.CellEditingTemplate = (DataTemplate)XamlReader.Load(CellETemp.ToString()); dgvRepAdviceList.Columns.Add(templateColumn); } #endregion } }Code
if (index == 0)Code
{Code
Str = "SrNo";Code
StringBuilder CellTemp = new StringBuilder();Code
CellTemp.Append(");Code
CellTemp.Append("xmlns='http://schemas.microsoft.com/winfx/");Code
CellTemp.Append("2006/xaml/presentation' ");Code
CellTemp.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' ");Code
CellTemp.Append("xmlns:local = 'clr-namespace:System.Windows.Controls");Code
CellTemp.Append(";assembly=System.Windows.Controls.Toolkit'>");Code
CellTemp.Append(");Code
CellTemp.Append("Text ='{Binding Path=" + Str + "}' Style='{StaticResource ContentTextStyle}' IsHitTestVisible='False' "); CellTemp.Append("/>");Code
CellTemp.Append("");Code
templateColumn.CellTemplate = (DataTemplate)XamlReader.Load(CellTemp.ToString()); dgvRepAdviceList.Columns.Add(templateColumn); }.....Code


Sanal Rajan139 reputationPosted May 24, 2017, 8:48 PM EDT