or

<asp:SqlDataSource ID="SqlDataSource_PT20" runat="server"> </asp:SqlDataSource> </asp:PlaceHolder> <asp:PlaceHolder ID="PlaceHolder2" runat="server"> <input type="hidden" id="RadGridClickedRowIndex" name="RadGridClickedRowIndex" value="1" /> <telerik:RadGrid ID="RadGrid_PT20" runat="server" AutoGenerateColumns="false" AllowMultiRowSelection="false" AllowPaging="True" AllowCustomPaging="True" PageSize="15" AllowAutomaticInserts="false" GridLines="None" CellPadding="0" AllowSorting="false" Skin="Default" OnItemDataBound="Att_Log_Translate" ItemStyle-VerticalAlign="Top" OnNeedDataSource="RadGrid_PT20_NeedDataSource"> <ExportSettings IgnorePaging="false" OpenInNewWindow="true"> <Pdf PageHeight="297mm" PageWidth="210mm" PageTitle="OnTime System Logs" /> </ExportSettings> <PagerStyle Mode="NextPrevAndNumeric"/> <MasterTableView Width="100%" CommandItemDisplay="Top" GridLines="None" AllowAutomaticInserts="false"> <CommandItemSettings ShowAddNewRecordButton="false" /> <CommandItemTemplate> <telerik:RadToolBar ID="RadToolBar_PT20" runat="server" Skin="Default" OnButtonClick="RadToolBar_PT20_CommandClick"> <Items> <telerik:RadToolBarDropDown Text="Export" ImageUrl="Images/pdf_icon.gif"> <Buttons> <telerik:RadToolBarButton Text="Export Current View" Group="Bold" CheckOnClick="true" AllowSelfUnCheck="true" CommandName="ExportToPDF" ImageUrl="Images/pdf_icon.gif"/> <telerik:RadToolBarButton Text="Export All Records" Group="Italic" CheckOnClick="true" AllowSelfUnCheck="true" /> </Buttons> </telerik:RadToolBarDropDown> </Items> </telerik:RadToolBar> </CommandItemTemplate> <Columns> <telerik:GridBoundColumn UniqueName="Log_ID" DataField="Attendance_Logs_Auto_ID" HeaderText="Log ID" Visible="false"/> <telerik:GridBoundColumn UniqueName="Employee_First_Name" DataField="Employee_First_Name" HeaderText="First Name" Visible="false"/> <telerik:GridTemplateColumn UniqueName="PT20_Left_Column" HeaderText="Type" HeaderStyle-Width="40%"> <ItemTemplate> <asp:Panel ID="Panel3" runat="server" CssClass="logs_table_text"> <asp:Literal ID="Literal_Att_Logs_DateTime" runat="server" Text='<%# Eval("Attendance_Logs_DateTime").ToString() %>'></asp:Literal> <br /> <asp:Literal ID="Literal2" runat="server" meta:resourcekey="Literal2Resource1" Text="T: "></asp:Literal> <asp:Literal ID="Literal_Att_Logs_Terminal_Name" runat="server" Text='<%# Eval("Terminal_Name").ToString() %>'></asp:Literal> </asp:Panel> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn UniqueName="PT20_Right_Column" HeaderText="Description" HeaderStyle-Width="60%"> <ItemTemplate> <asp:Panel ID="Panel4" runat="server" CssClass="logs_table_text" > <asp:Literal ID="Literal_Att_Logs_Employee_Name" runat="server" Text='<%# Eval("Employee_First_Name").ToString() %>'></asp:Literal> <asp:Literal ID="Literal_Att_Logs_Employee_Name1" runat="server" Text='<%# Eval("Employee_Last_Name").ToString() %>'></asp:Literal> <br /> <asp:Literal ID="Literal1" runat="server" meta:resourcekey="Literal1Resource1" Text="-"> </asp:Literal> <asp:Literal ID="Literal_Att_Logs_Type" runat="server" Text='<%# Eval("Attendance_Logs_Type").ToString() %>'> </asp:Literal> </asp:Panel> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </MasterTableView> <ClientSettings> <Selecting AllowRowSelect="true" /> <ClientEvents OnRowContextMenu="PT20_ContextMenu"></ClientEvents> </ClientSettings> </telerik:RadGrid> <telerik:RadContextMenu ID="RadMenu_PT20" runat="server" OnItemClick="RadMenu_PT20_ItemClick" Skin="Default" > <Items> <telerik:RadMenuItem Text="Go to Employee" /> <telerik:RadMenuItem Text="Go to Terminal" /> <telerik:RadMenuItem Text="Edit Record" /> </Items> <Targets> <telerik:ContextMenuControlTarget ControlID="RadGrid_PT20"/> </Targets> </telerik:RadContextMenu>public void ApplySkin(Control target){ if (target == null) { return; } if (!target.Visible) { return; } if (target is ISkinnableControl) { AvailableSkin skinToUse = AvailableSkins.Find(s => s.Name == Skin); if (!skinToUse.IsEmbedded) { RegisterControlSkin(skinToUse, target.GetType().Name); if (target.GetType().Name == "RadEditor") { RegisterControlSkin(skinToUse, "RadWindow"); RegisterControlSkin(skinToUse, "RadTabStrip"); RegisterControlSkin(skinToUse, "RadGrid"); } } //TODO: Need to have a flag on each item to determine if it is embedded or not ((ISkinnableControl)target).EnableEmbeddedSkins = skinToUse.IsEmbedded; ((ISkinnableControl)target).Skin = skinToUse.Name; } else { if (target.Controls.Count > 0) { foreach (Control child in target.Controls) { ApplySkin(child); } } }}void RegisterControlSkin(AvailableSkin Skin, string Control){ RadStyleSheetManager mgr = Page.Master.FindControl("RadStyleSheetManager1") as RadStyleSheetManager; string controlName = Control; if (Control.StartsWith("Rad")) { controlName = Control.Remove(0, 3); } if (!skinnedControls.Contains(controlName)) { string fileName = String.Format("{0}.{1}.{2}.{1}.css", Skin.Assembly, Skin.Name, controlName); StyleSheetReference skinRef = new StyleSheetReference(fileName, Skin.Assembly); mgr.StyleSheets.Add(skinRef); skinnedControls.Add(controlName); }}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);