| <telerik:RadWindow runat="server" ID="uiReleaseNotes" Height="545px" Width="800px" |
| Behaviors="Maximize" ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true" |
| VisibleStatusbar="false" VisibleTitlebar="true" NavigateUrl="ShowReleaseNotes.aspx" |
| Skin="Telerik"> |
| </telerik:RadWindow> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head id="Head1" runat="server"> |
| <title>Release Notes</title> |
| <script type="text/javascript"> |
| function GetRadWindow() //Get reference to window |
| { |
| var oWindow = null; |
| if (window.radWindow) |
| oWindow = window.radWindow; |
| else if (window.frameElement.radWindow) |
| oWindow = window.frameElement.radWindow; |
| return oWindow; |
| } |
| </script> |
| <style type="text/css"> |
| body, form, html |
| { |
| height: 100%; |
| margin: 0px; |
| padding: 0px; |
| } |
| </style> |
| <link href="../CSS/businessport.css" rel="stylesheet" type="text/css" /> |
| </head> |
| <body> |
| <form id="form2" runat="server"> |
| <div style="height:100%; width:100%; filter:progid:DXImageTransform.Microsoft.Gradient(endColorstr='#C0CFE2', startColorstr='#FFFFFF', gradientType='0');"> |
| <asp:ScriptManager ID="ScriptManager" runat="server" /> |
| <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" Skin="Sunset" ControlsToSkip="Scrollbars" /> |
| <div style="border: 1px solid #FFB700; margin-top: 25px; margin-bottom: 25px; width: 85%; |
| padding: 20px; background-color: #35435E;"> |
| <div style="width: 100%; height: 26px; text-align: right;"> |
| <asp:Button ID="cancelItemButton" runat="server" Text="Close" OnClick="cancelItemButton_Click" |
| Width="75px" /> |
| </div> |
| <div class="Gold Large"> |
| Release Notes - |
| <asp:Label ID="uiVersion" runat="server" Font-Size="Large"></asp:Label> |
| </div> |
| <table class="Small White"> |
| <tr> |
| <td> |
| <asp:Label ID="uiReleaseNotes" runat="server"></asp:Label> |
| </td> |
| </tr> |
| </table> |
| </div> |
| </div> |
| </form> |
| </body> |
| </html> |
My problem is
I use a self referencing grid. Im binding a List which has 2 objects. The 1st object has a property called ID set to 1 and ParentID set to 0. The second object has ParentID set to ID for FIrst Object(1). Now when i try to bind the list as datasource to the grid in Page Load,
I get the 1st record displayed and 2nd record as child to first record. The problem is in addition to that, i recieve a duplicate second record in the same level as 1st record.
Any help is appreciated.
I have attached a output which shows the wrong value. There the 2nd object is duplicated once in child view and in the same hierarchy as 1st node.
Following is the code
ASPX
| <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Organization.aspx.cs" Inherits="ConcordanceSample.Organization" %> |
| <%@ Register TagPrefix="telerik" Namespace="Telerik.Charting" Assembly="Telerik.Web.UI" %> |
| <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml" > |
| <head id="Head1" runat="server"> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <telerik:RadScriptManager runat="server" ID="ScriptManager1"> |
| </telerik:RadScriptManager> |
| <!-- content start --> |
| <div> |
| <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder> |
| <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="RadGrid1"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| </telerik:RadAjaxManager> |
| <telerik:RadGrid ID="RadGrid1" runat="server" |
| OnColumnCreated="RadGrid1_ColumnCreated" OnItemCreated="RadGrid1_ItemCreated" OnItemDataBound="RadGrid1_ItemDataBound"> |
| <MasterTableView HierarchyDefaultExpanded="false" HierarchyLoadMode="Client" AllowSorting="true" |
| DataKeyNames="ParentID,ID" Width="100%"> |
| <SelfHierarchySettings ParentKeyName="ParentID" KeyName="ID" /> |
| </MasterTableView> |
| <ClientSettings AllowExpandCollapse="true" /> |
| </telerik:RadGrid> |
| </div> |
| </form> |
| </body> |
| </html> |
| using System; |
| using System.Collections; |
| using System.Configuration; |
| using System.Data; |
| using System.Linq; |
| using System.Web; |
| using System.Web.Security; |
| using System.Web.UI; |
| using System.Web.UI.HtmlControls; |
| using System.Web.UI.WebControls; |
| using System.Web.UI.WebControls.WebParts; |
| using System.Xml.Linq; |
| using System.Collections.Generic; |
| using Telerik.Web.UI; |
| namespace ConcordanceSample |
| { |
| public partial class Organization : System.Web.UI.Page |
| { |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| if (!IsPostBack) |
| { |
| RadGrid1.DataSource = AddMatter(); |
| RadGrid1.DataBind(); |
| } |
| } |
| protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) |
| { |
| } |
| protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) |
| { |
| if (e.Column is GridExpandColumn) |
| { |
| e.Column.Visible = false; |
| } |
| else if (e.Column is GridBoundColumn) |
| { |
| e.Column.HeaderStyle.Width = Unit.Pixel(100); |
| } |
| } |
| public void Page_PreRenderComplete(object sender, EventArgs e) |
| { |
| HideExpandColumnRecursive(RadGrid1.MasterTableView); |
| } |
| public void HideExpandColumnRecursive(GridTableView tableView) |
| { |
| GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView); |
| foreach (GridNestedViewItem nestedViewItem in nestedViewItems) |
| { |
| foreach (GridTableView nestedView in nestedViewItem.NestedTableViews) |
| { |
| nestedView.Style["border"] = "0"; |
| Button MyExpandCollapseButton = (Button)nestedView.ParentItem.FindControl("MyExpandCollapseButton"); |
| if (nestedView.Items.Count == 0) |
| { |
| if (MyExpandCollapseButton != null) |
| { |
| MyExpandCollapseButton.Style["visibility"] = "hidden"; |
| } |
| nestedViewItem.Visible = false; |
| } |
| else |
| { |
| if (MyExpandCollapseButton != null) |
| { |
| MyExpandCollapseButton.Style.Remove("visibility"); |
| } |
| } |
| if (nestedView.HasDetailTables) |
| { |
| HideExpandColumnRecursive(nestedView); |
| } |
| } |
| } |
| } |
| protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) |
| { |
| CreateExpandCollapseButton(e.Item, "ID"); |
| if (e.Item is GridHeaderItem && e.Item.OwnerTableView != RadGrid1.MasterTableView) |
| { |
| e.Item.Style["display"] = "none"; |
| } |
| if (e.Item is GridNestedViewItem) |
| { |
| e.Item.Cells[0].Visible = false; |
| } |
| } |
| protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) |
| { |
| CreateExpandCollapseButton(e.Item, "ID"); |
| } |
| protected void RadGrid1_PreRender(object sender, EventArgs e) |
| { |
| if (!Page.IsPostBack) |
| { |
| } |
| } |
| public void CreateExpandCollapseButton(GridItem item, string columnUniqueName) |
| { |
| if (item is GridDataItem) |
| { |
| if (item.FindControl("MyExpandCollapseButton") == null) |
| { |
| Button button = new Button(); |
| button.Click += new EventHandler(button_Click); |
| button.CommandName = "ExpandCollapse"; |
| button.CssClass = (item.Expanded) ? "rgCollapse" : "rgExpand"; |
| button.ID = "MyExpandCollapseButton"; |
| if (item.OwnerTableView.HierarchyLoadMode == GridChildLoadMode.Client) |
| { |
| string script = String.Format(@"$find(""{0}"")._toggleExpand(this, event); return false;", item.Parent.Parent.ClientID); |
| button.OnClientClick = script; |
| } |
| int level = item.ItemIndexHierarchical.Split(':').Length; |
| if (level > 1) |
| { |
| button.Style["margin-left"] = level + 10 + "px"; |
| } |
| TableCell cell = ((GridDataItem)item)[columnUniqueName]; |
| cell.Controls.Add(button); |
| cell.Controls.Add(new LiteralControl(" ")); |
| cell.Controls.Add(new LiteralControl(((GridDataItem)item).GetDataKeyValue(columnUniqueName).ToString())); |
| } |
| } |
| } |
| void button_Click(object sender, EventArgs e) |
| { |
| ((Button)sender).CssClass = (((Button)sender).CssClass == "rgExpand") ? "rgCollapse" : "rgExpand"; |
| } |
| public List<MatterObject> AddMatter() |
| { |
| List<MatterObject> olistMatter = new List<MatterObject>(); |
| MatterObject objMatter = new MatterObject(); |
| objMatter.ID = 1; |
| objMatter.Name = "Parket & Parker"; |
| objMatter.CreatedBy = "Krishnan"; |
| objMatter.CreationDate = "2/17/2010"; |
| objMatter.LastModifiedDate = "2/17/2010"; |
| objMatter.LastModifiedBy = "Krishnan"; |
| objMatter.ParentID = 0; |
| olistMatter.Add(objMatter); |
| MatterObject objMatter1 = new MatterObject(); |
| objMatter1.ID = 2; |
| objMatter1.Name = "Lancer & Lancer"; |
| objMatter1.CreatedBy = "L.N.K"; |
| objMatter1.CreationDate = "2/17/2010"; |
| objMatter1.LastModifiedDate = "2/17/2010"; |
| objMatter1.LastModifiedBy = "Krishnan"; |
| objMatter1.ParentID = 1; |
| olistMatter.Add(objMatter1); |
| return olistMatter; |
| } |
| public List<MatterObject> AddChild() |
| { |
| List<MatterObject> olistMatter = new List<MatterObject>(); |
| MatterObject objMatter = new MatterObject(); |
| objMatter.ID = 2; |
| objMatter.Name = "Organization Folder 1"; |
| objMatter.CreatedBy = "LN"; |
| objMatter.CreationDate = "2/16/2010"; |
| objMatter.LastModifiedDate = "2/16/2010"; |
| objMatter.LastModifiedBy = "LN"; |
| olistMatter.Add(objMatter); |
| objMatter = new MatterObject(); |
| objMatter.ID = 3; |
| objMatter.Name = "Organization Folder 2"; |
| objMatter.CreatedBy = "Krishnan"; |
| objMatter.CreationDate = "2/15/2010"; |
| objMatter.LastModifiedDate = "2/15/2010"; |
| objMatter.LastModifiedBy = "Krishnan"; |
| olistMatter.Add(objMatter); |
| return olistMatter; |
| } |
| } |
| public class MatterObject |
| { |
| public int ID { get; set; } |
| public string Name { get; set; } |
| public string CreatedBy { get; set; } |
| public string CreationDate { get; set; } |
| public string LastModifiedDate { get; set; } |
| public string LastModifiedBy { get; set; } |
| public int ParentID { get; set; } |
| //public MatterChild Child { get; set; } |
| } |
| } |
EID = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][
"EID"].ToString();
But i need the above code for binding data when in EditMode, but causes an null error when click Insert Button.
So help me to solve this issue,
-Thanks
| <telerik:radgrid id="myGrid" runat="server" DatasourceID="dsCustomers" AllowAutomaticInserts="true" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true"> |
| <MasterTableView CommandItemDisplay="top" DataSourceId="dsCustomers" DataKeyNames="CustomerId" EditMode="EditForms"> |
| <Columns> |
| <telerik:GridEditCommandColumn ButtonType="ImageButton" EditText="Edit" /> |
| <telerik:GridBoundColumn HeaderText="Title" DataField="Title.Description" /> |
| <telerik:GridBoundColumn HeaderText="Name" DataField="Name" /> |
| <telerik:GridButtonColumn ConfirmText="Delete this Customer?" ConfirmDialogType="Classic" ConfirmTitle="Delete" |
| ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn" /> |
| </Columns> |
| <EditFormSettings EditFormType="Template"> |
| <FormTemplate> |
| <table> |
| <tr> |
| <td> |
| <telerik:RadComboBox id="cmbTitle" runat="server" DataSourceID="dsTitles" AppendDataBoundItems="true" |
| DataTextField="Description" DataValueField="Id" SelectedValue='<%# Bind("Title.Id") %>' > |
| <Items><telerik:RadComboBoxItem Value="0" Text="" Selected="true" /></Items> |
| </telerik:RadcomboBox> |
| </td> |
| <td> |
| <telerik:RadTextBox id="txtName" runat="server" Text='<% Bind("Name") %>;' /> |
| </td> </tr> </table> |
| </FormTemplate> |
| </EditFormSettings> |
| </MasterTableView> |
| </telerik:radgrid> |
| <asp:EntityDataSource ID="dsCustomers" runat="server" ConnectionString="name=CustomerEntities" DefaultContainerName="CustomerEntities" EnableUpdate="true" EnableInsert="true" EnableDelete="true" EntitySetName="Customer" Include="Title" /> |
| <asp:EntityDataSource ID="dsTitles" runat="server" ConnectionString="name=CustomerEntities" DefaultContainerName="CustomerEntities" EntitySetName="Title" /> |
Hi,
In Rad grid Control, there are 2 TemplateColums (Start time and end time) and it has two RadTimePicker control for EditItemTemplate .im using the master page as well.
I want to validate that end time value is greater than the start time .
How to use Compare Validator?
Can you plz tell me the way of doing this.because this is ugent.
| <telerik:GridTemplateColumn HeaderText="Starttime" UniqueName="Starttime" > |
| <EditItemTemplate> |
| <telerik:RadTimePicker ID="rtpStartTime" runat="server"> |
| </telerik:RadTimePicker> |
| </EditItemTemplate> |
| <ItemTemplate> |
| <asp:Label ID="lblStarttime" runat="server" Text='<%# Eval("StartTime","{0:t}") %>'></asp:Label> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn HeaderText="End time" UniqueName="EndTime"> |
| <EditItemTemplate> |
| <telerik:RadTimePicker ID="rtpEndTime" runat="server" |
| </telerik:RadTimePicker> |
| </EditItemTemplate> |
| <ItemTemplate> |
| <asp:Label ID="lblEndTime" runat="server" Text='<%# Eval("EndTime", "{0:t}") %>'></asp:Label> |
| </ItemTemplate> |
Thanks
Waruni
| <telerik:GridDateTimeColumn HeaderText="Start Date" SortExpression="startDate" UniqueName="startDate" AutoPostBackOnFilter="true" DataField="startDate" |
| FilterControlWidth="110px" PickerType="DatePicker" DataFormatString="{0:d/M/yyyy}" DataType="System.DateTime"> |
| </telerik:GridDateTimeColumn> |
| Private Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated |
| If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then |
| Dim item As GridEditableItem = CType(e.Item, GridEditableItem) |
| Dim startColumnEditor As GridDateTimeColumnEditor = TryCast(DirectCast(e.Item, GridEditableItem).EditManager.GetColumnEditor("startDate"), GridDateTimeColumnEditor) |
| Dim startCell As TableCell = DirectCast(startColumnEditor.PickerControl.Parent, TableCell) |
| Dim compareValidator1 As New CompareValidator() |
| compareValidator1.ID = "compareValidator1" |
| compareValidator1.ControlToValidate = startColumnEditor.PickerControl.ID |
| compareValidator1.[Operator] = ValidationCompareOperator.DataTypeCheck |
| compareValidator1.Type = ValidationDataType.[Date] |
| compareValidator1.ErrorMessage = "Invalid date. " |
| compareValidator1.Display = ValidatorDisplay.Dynamic |
| startCell.Controls.Add(compareValidator1) |
| Dim compareValidator3 As New CompareValidator() |
| compareValidator3.ID = "compareValidator3" |
| compareValidator3.ControlToValidate = startColumnEditor.PickerControl.ID |
| compareValidator3.[Operator] = ValidationCompareOperator.GreaterThanEqual |
| compareValidator3.Type = ValidationDataType.[Date] |
| compareValidator3.ErrorMessage = "Date can't be earlier than today" |
| compareValidator3.ValueToCompare = DateTime.Now.ToShortDateString() |
| compareValidator3.Display = ValidatorDisplay.Dynamic |
| startCell.Controls.Add(compareValidator3) |
| End If |
| End Sub |
| Private Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand |
| If e.CommandName = "Update" Then |
| If Page.IsValid Then |
| e.Item.Edit = False |
| End If |
| ElseIf e.CommandName = "PerformInsert" Then |
| If Page.IsValid Then |
| e.Canceled = True |
| e.Item.OwnerTableView.IsItemInserted = False |
| e.Item.OwnerTableView.Rebind() |
| End If |
| ElseIf e.CommandName = "Delete" Then |
| End If |
| End Sub |
| <telerik:RadGrid ID="CnsGrid" runat="server" Style="position: static" AllowFilteringByColumn="True" |
| AllowPaging="True" AllowSorting="True" GridLines="None" PageSize="15" ShowGroupPanel="True" Skin="Simple" AllowCustomPaging="True"> |
| <GroupPanel Text="Arrastre un título de columna aquí para agrupar por dicha columna"> |
| </GroupPanel> |
| <PagerStyle FirstPageToolTip="Primera página" LastPageToolTip="Ùltima Página" |
| NextPagesToolTip="Próximas Páginas" NextPageToolTip="Próxima Página" |
| PrevPagesToolTip="Página Anterior" PrevPageToolTip="Página Anterior" PagerTextFormat="Cambiar página: {4} &nbsp;Página <strong>{0}</strong> de <strong>{1}</strong>, items <strong>{2}</strong> a <strong>{3}</strong> de <strong>{5}</strong>." /> |
| <GroupingSettings CollapseTooltip="Contraer grupo" ExpandTooltip="Expandir grupo" |
| GroupContinuedFormatString="... grupo viene de la página anterior" GroupContinuesFormatString="Grupo continua en la siguiente página..." |
| ShowUnGroupButton="True" UnGroupButtonTooltip="Click aqui para desagrupar" UnGroupTooltip="Arrastre fuera para eliminar el grupo por dicha columna" /> |
| <SortingSettings SortedAscToolTip="Orden Asc" SortedDescToolTip="Orden Desc" SortToolTip="Clic aquí para ordenar" /> |
| <StatusBarSettings LoadingText="Cargando..." ReadyText="Listo" /> |
| <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /> |
| <HeaderStyle Font-Bold="True" HorizontalAlign="Center" VerticalAlign="Middle" /> |
| <FilterItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /> |
| <AlternatingItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /> |
| <ClientSettings EnableRowHoverStyle="True"> |
| <Selecting AllowRowSelect="True" /> |
| </ClientSettings> |
| <SelectedItemStyle BackColor="#FFC080" /> |
| </telerik:RadGrid> |
| Dim ArrRes() As String = Nothing |
| Dim index As Integer |
| Session("Cns_sn_cancel") = False |
| Try |
| For index = 2 To CnsGrid.Items(Me.CnsGrid.SelectedIndexes(0)).Cells.Count - 1 |
| 'HERE I ALWAYS GET AN ERROR |
| 'BECAUSE THERE'S NO ROW SELECTED |
| ReDim Preserve ArrRes(index) |
| ArrRes(index - 2) = CnsGrid.Items(Me.CnsGrid.SelectedIndexes(0)).Cells(index).Text |
| Next |
| Session("ResConsulta") = ArrRes |
| Catch ex As Exception |
| Session("CNS_sn_error") = True |
| Session("Cns_error") = ex.Message.ToString |
| Finally |
| Dim strScript As String |
| strScript = "<script language=javascript> " |
| strScript += "window.close();" |
| strScript += "</script>" |
| ClientScript.RegisterStartupScript(Me.Page.GetType(), "CierraConsulta", strScript) |
| End Try |