or
public class RadGridHeaderTemplate : ITemplate {
private string _columName; public string ColumName { get { return _columName; } set { _columName = value; } } public RadGridHeaderTemplate(string cName) { _columName = cName; } public RadGridHeaderTemplate() { } public void InstantiateIn(Control container) { Table table = new Table(); TableRow row1 = new TableRow(); TableRow row2 = new TableRow(); TableCell cell11 = new TableCell(); TableCell cell21 = new TableCell(); TableCell cell22 = new TableCell(); cell11.ColumnSpan = 2; cell11.BackColor = System.Drawing.Color.Aqua; cell11.Text = ColumName; row1.Cells.Add(cell11); cell21.Text = "Valores Actuais"; cell21.BackColor = System.Drawing.Color.Aqua; row2.Cells.Add(cell21); cell22.Text = "Valores Novos"; cell22.BackColor = System.Drawing.Color.Aqua; row2.Cells.Add(cell22); table.Rows.Add(row1); table.Rows.Add(row2); container.Controls.Add(table); } }public class RadGridItemTemplate: ITemplate { protected LiteralControl lControl; protected RangeValidator validatorTextBox; protected RadNumericTextBox textBox; private string _columnName; private string _headerName; private bool _isOrigin;
public string ColumnName { get { return _columnName; } set { _columnName = value; } } public string HeaderName { get { return _headerName; } set { _headerName = value; } } public bool IsOrigin { get { return _isOrigin; } set { _isOrigin = value; } }
public RadGridItemTemplate(string cName, string hName, bool isOrigin) { _columnName = cName; _headerName = hName; _isOrigin = isOrigin; } public RadGridItemTemplate() {
}
public void InstantiateIn(Control container) { Table table = new Table(); table.BorderColor = System.Drawing.Color.Black; table.Style.Add(HtmlTextWriterStyle.BorderWidth, "1px"); TableRow row1 = new TableRow(); textBox = new RadNumericTextBox(); textBox.ID = "templateColumnTextBox"; textBox.Type = NumericType.Currency; textBox.ClientEvents.OnBlur = "Blur"; textBox.ClientEvents.OnFocus = "Focus"; textBox.Width = Unit.Pixel(60); if (IsOrigin) { lControl = new LiteralControl(); lControl.ID = "lControl"; lControl.DataBinding += lControl_DataBinding; TableCell cell11 = new TableCell(); TableCell cell12 = new TableCell(); cell11.Width = Unit.Pixel(50); cell11.Style.Add(HtmlTextWriterStyle.TextAlign, "center"); cell11.Controls.Add(lControl); cell12.Controls.Add(textBox); row1.Cells.Add(cell11); row1.Cells.Add(cell12); } else { TableCell cell11 = new TableCell(); cell11.Controls.Add(textBox); row1.Cells.Add(cell11); } table.Rows.Add(row1); container.Controls.Add(table); }
public void lControl_DataBinding(object sender, EventArgs e) { LiteralControl l = (LiteralControl)sender; GridDataItem container = (GridDataItem)l.NamingContainer; l.Text = String.Format("{0:C}", Convert.ToDouble(((DataRowView) container.DataItem)[ColumnName])); } textBox.ClientEvents.OnLoad = "Load"; public class RadGridFooterTemplate : ITemplate { protected RadNumericTextBox textBox; private bool _isOrigin; public bool IsOrigin { get { return _isOrigin; } set { _isOrigin = value; } } public RadGridFooterTemplate(bool isOrigin) { _isOrigin = isOrigin; } public RadGridFooterTemplate() { } public void InstantiateIn(Control container) { Table table = new Table(); TableRow row1 = new TableRow(); textBox = new RadNumericTextBox(); textBox.ID = "footerColumnTextBox"; textBox.Type = NumericType.Currency; textBox.ClientEvents.OnLoad = "Load"; textBox.Enabled = false; if (IsOrigin) { TableCell cell11 = new TableCell(); TableCell cell12 = new TableCell(); cell11.Text = "Total"; cell12.Controls.Add(textBox); row1.Cells.Add(cell11); row1.Cells.Add(cell12); } else { TableCell cell11 = new TableCell(); cell11.Controls.Add(textBox); row1.Cells.Add(cell11); } table.Rows.Add(row1); container.Controls.Add(table); } } RadGrid radGrid = new RadGrid(); radGrid.ID = "gvSetValues"; radGrid.DataSource = buildDataTable;
radGrid.AllowPaging = false; radGrid.AllowSorting = false; radGrid.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric; radGrid.AutoGenerateColumns = false; radGrid.ShowStatusBar = true; radGrid.ShowFooter = true; radGrid.MasterTableView.ShowFooter = true; GridBoundColumn boundColumn = new GridBoundColumn(); boundColumn.DataField = "Meses"; boundColumn.UniqueName = "Meses"; boundColumn.HeaderText = "Meses/PPI"; radGrid.MasterTableView.Columns.Add(boundColumn); foreach (DataColumn column in buildDataTable.Columns) { //Add origins Columns if (column.ColumnName.StartsWith("O_")) { GridTemplateColumn templateColumn = new GridTemplateColumn(); templateColumn.HeaderTemplate = new RadGridHeaderTemplate(column.ColumnName.Split('_')[1]); templateColumn.ItemTemplate = new RadGridItemTemplate(column.ColumnName, column.ColumnName.Split('_')[1], true); templateColumn.FooterTemplate = new RadGridFooterTemplate(true); radGrid.MasterTableView.Columns.Add(templateColumn); templateColumn.UniqueName = "OldValues"; } //Add Destinations Columns if (column.ColumnName.StartsWith("D_")) { GridTemplateColumn templateColumn = new GridTemplateColumn(); templateColumn.HeaderText = column.ColumnName.Split('_')[1]; templateColumn.ItemTemplate = new RadGridItemTemplate(column.ColumnName, column.ColumnName.Split('_')[1], false); templateColumn.FooterTemplate = new RadGridFooterTemplate(false); radGrid.MasterTableView.Columns.Add(templateColumn); } } radGrid.DataBind(); phGvMoveValues.Controls.Add(radGrid);j_inComboText.value = Description;
j_inComboVal.value = StatusId;
$find(
"<%= RadAjaxManager1.ClientID %>").ajaxRequest();
On server side i implement
if (rcbStatus.SelectedIndex == 0)
rcbStatus.Items.Remove(0);
RadComboBoxItem ps = new RadComboBoxItem();
ps.Text = inComboText.value ;
ps.Value = inComboVal.Value ;
rcbStatus.Items.Insert(0, ps);
rcbStatus.SelectedIndex = 0;
It shows that my value is set ok in the combo but not refresh it to appear in the header of the combo?
I have installed trail version of Telerik controls. Could you tell me, can I use radgrid control to my existing asp.net application?
I am not interested to create another new web application for radgrid usability
Suggest me if I am wrong