foreach (var ColumnHeader in HistRepcolumnName)
{
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("<DataTemplate "); 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("<TextBlock "); CellTemp.Append("Text ='{Binding Path=" + Str + "}' Style='{StaticResource ContentTextStyle}' IsHitTestVisible='False' "); CellTemp.Append("/>"); CellTemp.Append("</DataTemplate>"); templateColumn.CellTemplate = (DataTemplate)XamlReader.Load(CellTemp.ToString()); dgvRepAdviceList.Columns.Add(templateColumn); } else if (index == 1) { Str = "RepName"; StringBuilder CellTemp = new StringBuilder(); CellTemp.Append("<DataTemplate "); 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("<TextBlock "); CellTemp.Append("Text ='{Binding Path=" + Str + ",Mode=TwoWay,NotifyOnValidationError=True, ValidatesOnExceptions=True}' Style='{StaticResource ContentTextStyle}' IsHitTestVisible='True' "); CellTemp.Append("Margin='4'/>"); CellTemp.Append("</DataTemplate>"); StringBuilder CellETemp = new StringBuilder(); CellETemp.Append("<DataTemplate "); 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("<TextBlock "); CellETemp.Append("Text ='{Binding Path=" + Str + ",Mode=TwoWay,NotifyOnValidationError=True, ValidatesOnExceptions=True}' Style='{StaticResource ContentTextStyle}' IsHitTestVisible='False' "); CellETemp.Append("Margin='4'/>"); CellETemp.Append("</DataTemplate>"); templateColumn.CellTemplate = (DataTemplate)XamlReader.Load(CellTemp.ToString()); templateColumn.CellEditingTemplate = (DataTemplate)XamlReader.Load(CellETemp.ToString()); dgvRepAdviceList.Columns.Add(templateColumn); } #endregion } }
if (index == 0)
{
Str = "SrNo";
StringBuilder CellTemp = new StringBuilder();
CellTemp.Append("<DataTemplate ");
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("<TextBlock ");
CellTemp.Append("Text ='{Binding Path=" + Str + "}' Style='{StaticResource ContentTextStyle}' IsHitTestVisible='False' "); CellTemp.Append("/>");
CellTemp.Append("</DataTemplate>");
templateColumn.CellTemplate = (DataTemplate)XamlReader.Load(CellTemp.ToString()); dgvRepAdviceList.Columns.Add(templateColumn); }
.....