Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
99 views

Hi,
I have used the following namespace in my project.
using Telerik.Web.UI.GridExcelBuilder;
using xls = Telerik.Web.UI.ExportInfrastructure;
But it shows type are namespce ExportInfrastructure doesnt exist in the Telerik.Web.UI namespace.I have to add any reference in bin folder?

Regards,
Margret

Daniel
Telerik team
 answered on 06 Aug 2013
1 answer
194 views
Hello,

I have a hierarchical grid with MasterTableView and DetailTable (see below) with following problems:

  1. When running the example with multiple outstanding Add or Update forms, clicking on either the insert or update link will validate all the forms as shown in the attached MultipleOpenForm.png. Is there a way to prevent the validation of all outstanding forms and only restrict validation to the form where user click insert or update link? I tried to use validation group but could not find a way to link it to the insert or update link. Would greatly appreciate it if you can show me an example of how to do that for the RadGrid
  2. In order to prevent outstanding multiple forms open at the same time, I have added the following code to reset all outstanding edit form as shown below:
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
        {
            //Clear and reset all outstanding edit form
            e.Item.OwnerTableView.IsItemInserted = false;
            e.Item.OwnerTableView.ClearEditItems();
            e.Item.OwnerTableView.ClearChildEditItems();
    Add these codes will close all outstanding forms and will only allow one form open at a given time. Unfortunately, user will no longer able to insert or update an item when clicking on the insert or update link. The form will close without calling the Insert or Update events as well as other events defined in the RadGrid as shown below:
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" OnNeedDataSource="RadGrid1_NeedDataSource"
        OnDetailTableDataBind="RadGrid1_DetailTableDataBind" OnInsertCommand="RadGrid1_InsertCommand"
        OnUpdateCommand="RadGrid1_UpdateCommand" OnDeleteCommand="RadGrid1_DeleteCommand"
        OnEditCommand="RadGrid1_EditCommand" OnItemCreated="RadGrid1_ItemCreated" OnItemDataBound="RadGrid1_ItemDataBound"
        OnItemCommand="RadGrid1_ItemCommand">
    Only the delete event work. I searched the entire forum but did not find a solution to this problem. Can you please help to resolve this problem. It is a show stopper for us.
  3. The Date (Birth Date) RequiredField validation does not work for the DetailTable GridTableView even though it is exactly the same as the Parent Birth Date (see MultipleOpenForm.png). Can you tell me what wrong with the Child Date?
    <DetailTables>
         <telerik:GridTableView DataKeyNames="ID,DependentTobaccoUsage,DependentWellnessFactor"
             Name="Child" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add new dependent">
             <Columns>
                 <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID" ReadOnly="true"
                     Visible="false">
                 </telerik:GridBoundColumn>
                 <telerik:GridDateTimeColumn DataField="DependentDOB" HeaderText="Birth Date<span style='color:#CD4800'>*</span>"
                     SortExpression="DependentDOB" UniqueName="DependentDOB" DataFormatString="{0:MM/dd/yyyy}"
                     HeaderStyle-CssClass="bold" ColumnValidationSettings-EnableRequiredFieldValidation="True">
                     <ColumnValidationSettings EnableRequiredFieldValidation="true" RequiredFieldValidator-Display="Dynamic">
                         <RequiredFieldValidator ForeColor="Red" Text="*This field is required">
                         </RequiredFieldValidator>
                     </ColumnValidationSettings>
                 </telerik:GridDateTimeColumn>

Thanks in advance for your help!

Here is the aspx we use.

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="TestWebTelerik._Default" %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        Welcome to ASP.NET!
    </h2>
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" OnNeedDataSource="RadGrid1_NeedDataSource"
            OnDetailTableDataBind="RadGrid1_DetailTableDataBind" OnInsertCommand="RadGrid1_InsertCommand"
            OnUpdateCommand="RadGrid1_UpdateCommand" OnDeleteCommand="RadGrid1_DeleteCommand"
            OnEditCommand="RadGrid1_EditCommand" OnItemCreated="RadGrid1_ItemCreated" OnItemDataBound="RadGrid1_ItemDataBound"
            OnItemCommand="RadGrid1_ItemCommand">
            <MasterTableView DataKeyNames="ID,TobaccoUsage,WellnessFactor,MedicalClass,DentalClass"
                Name="Parent" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add new subscriber"
                ExpandCollapseColumn-ButtonType="LinkButton">
                <Columns>
                    <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID" ReadOnly="true"
                        Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="MedicalClass" UniqueName="MedicalClass" HeaderText="MedicalClass"
                        ReadOnly="true" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="DentalClass" UniqueName="DentalClass" HeaderText="DentalClass"
                        ReadOnly="true" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridDateTimeColumn DataField="DOB" HeaderText="Birth Date<span style='color:#CD4800'>*</span>"
                        SortExpression="DOB" UniqueName="DOB" DataFormatString="{0:MM/dd/yyyy}" HeaderStyle-CssClass="bold"
                        ColumnValidationSettings-EnableRequiredFieldValidation="True">
                        <ColumnValidationSettings EnableRequiredFieldValidation="true" RequiredFieldValidator-Display="Dynamic">
                            <RequiredFieldValidator ForeColor="Red" Text="*This field is required">
                            </RequiredFieldValidator>
                        </ColumnValidationSettings>
                    </telerik:GridDateTimeColumn>
                    <telerik:GridBoundColumn DataField="ZipCode" UniqueName="ZipCode" HeaderText="Zip Code<span style='color:#CD4800'>*</span>"
                        DataFormatString="{0:#####-0000}">
                        <ColumnValidationSettings EnableRequiredFieldValidation="true" RequiredFieldValidator-CssClass="inline"
                            RequiredFieldValidator-Display="Dynamic">
                            <RequiredFieldValidator ForeColor="Red" Text="*This field is required">
                            </RequiredFieldValidator>
                        </ColumnValidationSettings>
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn HeaderText="Tobacco Usage<span style='color:#CD4800'>*</span>">
                        <ItemTemplate>
                            <%#DataBinder.Eval(Container.DataItem, "TobaccoUsage")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadComboBox Height="100px" Width="150px" Skin="WebBlue" ID="TobaccoUsageComboBox"
                                DataTextField="TobaccoUsage" DataValueField="TobaccoUsage" EmptyMessage="Please Select..."
                                runat="server" EnableVirtualScrolling="true" MarkFirstMatch="true" AllowCustomText="true"
                                CausesValidation="false" AutoPostBack="false" NoWrap="True">
                                <Items>
                                    <telerik:RadComboBoxItem Text="Yes" Value="Yes"></telerik:RadComboBoxItem>
                                    <telerik:RadComboBoxItem Text="No" Value="No"></telerik:RadComboBoxItem>
                                </Items>
                            </telerik:RadComboBox>
                            <asp:RequiredFieldValidator ID="ValidateTobaccoUsageComboBox" runat="server" ControlToValidate="TobaccoUsageComboBox"
                                ErrorMessage="*This field is required" InitialValue="" ForeColor="Red">
                            </asp:RequiredFieldValidator>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn HeaderText="Wellness Factor<span style='color:#CD4800'>*</span>">
                        <ItemTemplate>
                            <%#DataBinder.Eval(Container.DataItem, "WellnessFactor")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadComboBox Height="100px" Width="150px" Skin="WebBlue" ID="WellnessFactorComboBox"
                                DataTextField="WellnessFactor" DataValueField="WellnessFactor" EmptyMessage="Please Select..."
                                runat="server" EnableVirtualScrolling="true" MarkFirstMatch="true" AllowCustomText="true"
                                CausesValidation="false" AutoPostBack="false" NoWrap="True">
                                <Items>
                                    <telerik:RadComboBoxItem Text="Excellent" Value="Excellent"></telerik:RadComboBoxItem>
                                    <telerik:RadComboBoxItem Text="VeryGood" Value="VeryGood"></telerik:RadComboBoxItem>
                                    <telerik:RadComboBoxItem Text="Good" Value="Good"></telerik:RadComboBoxItem>
                                    <telerik:RadComboBoxItem Text="Fair" Value="Fair"></telerik:RadComboBoxItem>
                                    <telerik:RadComboBoxItem Text="Poor" Value="Poor"></telerik:RadComboBoxItem>
                                </Items>
                            </telerik:RadComboBox>
                            <asp:RequiredFieldValidator ID="ValidateWellnessFactorComboBox" runat="server" ControlToValidate="WellnessFactorComboBox"
                                ErrorMessage="*This field is required" InitialValue="" ForeColor="Red">
                            </asp:RequiredFieldValidator>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn HeaderText="Medical Class<span style='color:#CD4800'>*</span>">
                        <ItemTemplate>
                            <%#DataBinder.Eval(Container.DataItem, "MedicalClassDisplay")%>
                            <%--Medical Class--%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadComboBox Height="100px" Width="150px" Skin="WebBlue" ID="MedicalClassComboBox"
                                DataTextField="MedicalClassDisplay" DataValueField="MedicalClass" EmptyMessage="Please Select..."
                                runat="server" EnableVirtualScrolling="true" MarkFirstMatch="true" AllowCustomText="true"
                                CausesValidation="false" AutoPostBack="false" NoWrap="True">
                                <Items>
                                    <telerik:RadComboBoxItem Text="None" Value="None"></telerik:RadComboBoxItem>
                                    <telerik:RadComboBoxItem Text="Individual Only" Value="INDIV"></telerik:RadComboBoxItem>
                                    <telerik:RadComboBoxItem Text="Employee and Spouse" Value="INDIVS"></telerik:RadComboBoxItem>
                                    <telerik:RadComboBoxItem Text="Employee and 1 Child" Value="INDIV1"></telerik:RadComboBoxItem>
                                    <telerik:RadComboBoxItem Text="Employee and Children" Value="INDIVC"></telerik:RadComboBoxItem>
                                    <telerik:RadComboBoxItem Text="Full Family" Value="FAMILY"></telerik:RadComboBoxItem>
                                </Items>
                            </telerik:RadComboBox>
                            <asp:RequiredFieldValidator ID="ValidateMedicalClassComboBox" runat="server" ControlToValidate="MedicalClassComboBox"
                                ErrorMessage="*This field is required" InitialValue="" ForeColor="Red">
                            </asp:RequiredFieldValidator>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn HeaderText="Dental Class<span style='color:#CD4800'>*</span>">
                        <ItemTemplate>
                            <%#DataBinder.Eval(Container.DataItem, "DentalClassDisplay")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadComboBox Height="100px" Width="150px" Skin="WebBlue" ID="DentalClassComboBox"
                                DataTextField="DentalClassDisplay" DataValueField="DentalClass" EmptyMessage="Please Select..."
                                runat="server" EnableVirtualScrolling="true" MarkFirstMatch="true" AllowCustomText="true"
                                CausesValidation="false" AutoPostBack="false" NoWrap="True">
                                <Items>
                                    <telerik:RadComboBoxItem Text="None" Value="None"></telerik:RadComboBoxItem>
                                    <telerik:RadComboBoxItem Text="Individual Only" Value="INDIV"></telerik:RadComboBoxItem>
                                    <telerik:RadComboBoxItem Text="Employee and Spouse" Value="INDIVS"></telerik:RadComboBoxItem>
                                    <telerik:RadComboBoxItem Text="Employee and 1 Child" Value="INDIV1"></telerik:RadComboBoxItem>
                                    <telerik:RadComboBoxItem Text="Employee and Children" Value="INDIVC"></telerik:RadComboBoxItem>
                                    <telerik:RadComboBoxItem Text="Full Family" Value="FAMILY"></telerik:RadComboBoxItem>
                                </Items>
                            </telerik:RadComboBox>
                            <asp:RequiredFieldValidator ID="ValidateDentalClassComboBox" runat="server" ControlToValidate="DentalClassComboBox"
                                ErrorMessage="*This field is required" InitialValue="" ForeColor="Red">
                            </asp:RequiredFieldValidator>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridEditCommandColumn>
                    </telerik:GridEditCommandColumn>
                    <telerik:GridButtonColumn CommandName="Delete" Text="Delete" ConfirmText="Delete record?">
                    </telerik:GridButtonColumn>
                </Columns>
                <DetailTables>
                    <telerik:GridTableView DataKeyNames="ID,DependentTobaccoUsage,DependentWellnessFactor"
                        Name="Child" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add new dependent">
                        <Columns>
                            <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID" ReadOnly="true"
                                Visible="false">
                            </telerik:GridBoundColumn>
                            <telerik:GridDateTimeColumn DataField="DependentDOB" HeaderText="Birth Date<span style='color:#CD4800'>*</span>"
                                SortExpression="DependentDOB" UniqueName="DependentDOB" DataFormatString="{0:MM/dd/yyyy}"
                                HeaderStyle-CssClass="bold" ColumnValidationSettings-EnableRequiredFieldValidation="True">
                                <ColumnValidationSettings EnableRequiredFieldValidation="true" RequiredFieldValidator-Display="Dynamic">
                                    <RequiredFieldValidator ForeColor="Red" Text="*This field is required">
                                    </RequiredFieldValidator>
                                </ColumnValidationSettings>
                            </telerik:GridDateTimeColumn>
                            <telerik:GridTemplateColumn HeaderText="Tobacco Usage<span style='color:#CD4800'>*</span>">
                                <ItemTemplate>
                                    <%#DataBinder.Eval(Container.DataItem, "DependentTobaccoUsage")%>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <telerik:RadComboBox Height="100px" Width="150px" Skin="WebBlue" ID="DependentTobaccoUsageComboBox"
                                        DataTextField="DependentTobaccoUsage" DataValueField="DependentTobaccoUsage"
                                        EmptyMessage="Please Select..." runat="server" EnableVirtualScrolling="true"
                                        MarkFirstMatch="true" AllowCustomText="true" CausesValidation="false" AutoPostBack="false"
                                        NoWrap="True">
                                        <Items>
                                            <telerik:RadComboBoxItem Text="Yes" Value="Yes"></telerik:RadComboBoxItem>
                                            <telerik:RadComboBoxItem Text="No" Value="No"></telerik:RadComboBoxItem>
                                        </Items>
                                    </telerik:RadComboBox>
                                    <asp:RequiredFieldValidator ID="ValidateDependentTobaccoUsageComboBox" runat="server"
                                        ControlToValidate="DependentTobaccoUsageComboBox" ErrorMessage="*This field is required"
                                        InitialValue="" ForeColor="Red">
                                    </asp:RequiredFieldValidator>
                                </EditItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn HeaderText="Wellness Factor<span style='color:#CD4800'>*</span>">
                                <ItemTemplate>
                                    <%#DataBinder.Eval(Container.DataItem, "DependentWellnessFactor")%>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <telerik:RadComboBox Height="100px" Width="150px" Skin="WebBlue" ID="DependentWellnessFactorComboBox"
                                        DataTextField="DependentWellnessFactor" DataValueField="DependentWellnessFactor"
                                        EmptyMessage="Please Select..." runat="server" EnableVirtualScrolling="true"
                                        MarkFirstMatch="true" AllowCustomText="true" CausesValidation="false" AutoPostBack="false"
                                        NoWrap="True">
                                        <Items>
                                            <telerik:RadComboBoxItem Text="Excellent" Value="Excellent"></telerik:RadComboBoxItem>
                                            <telerik:RadComboBoxItem Text="VeryGood" Value="VeryGood"></telerik:RadComboBoxItem>
                                            <telerik:RadComboBoxItem Text="Good" Value="Good"></telerik:RadComboBoxItem>
                                            <telerik:RadComboBoxItem Text="Fair" Value="Fair"></telerik:RadComboBoxItem>
                                            <telerik:RadComboBoxItem Text="Poor" Value="Poor"></telerik:RadComboBoxItem>
                                        </Items>
                                    </telerik:RadComboBox>
                                    <asp:RequiredFieldValidator ID="ValidateDependentWellnessFactorComboBox" runat="server"
                                        ControlToValidate="DependentWellnessFactorComboBox" ErrorMessage="*This field is required"
                                        InitialValue="" ForeColor="Red">
                                    </asp:RequiredFieldValidator>
                                </EditItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridEditCommandColumn>
                            </telerik:GridEditCommandColumn>
                            <telerik:GridButtonColumn CommandName="Delete" Text="Delete" ConfirmText="Delete record?">
                            </telerik:GridButtonColumn>
                        </Columns>
                    </telerik:GridTableView>
                </DetailTables>
            </MasterTableView>
        </telerik:RadGrid>
    </telerik:RadAjaxPanel>
    <p>
        To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">
            www.asp.net</a>.
    </p>
    <p>
        You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&;clcid=0x409"
            title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
    </p>
</asp:Content>

Here is the code behind file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
 
namespace TestWebTelerik
{
    [Serializable]
    public class Child
    {
        public int ID {get; set;}
        public DateTime DependentDOB { get; set; }
        public string DependentTobaccoUsage { get; set; }
        public string DependentWellnessFactor { get; set; }
        public Child(int id, DateTime dob, string tobaccoUsage, string wellnessFactor)
        {
            ID = id;
            DependentDOB = dob;
            DependentTobaccoUsage = tobaccoUsage;
            DependentWellnessFactor = wellnessFactor;
        }
    }
 
    [Serializable]
    public class ParentChild
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public DateTime DOB { get; set; }
        public string ZipCode { get; set; }
        public string TobaccoUsage { get; set; }
        public string WellnessFactor { get; set; }
        public string MedicalClass { get; set; }
        public string MedicalClassDisplay { get; set; }
        public string DentalClass { get; set; }
        public string DentalClassDisplay { get; set; }
        public List<Child> listChild { get; set; }
        public ParentChild(int id, string name, DateTime dob, string zipCode,
            string tobaccoUsage, string wellnessFactor,
            string medicalClass, string medicalClassDisplay,
            string dentalClass, string dentalClassDisplay)
        {
            ID = id;
            Name = name;
            DOB = dob;
            ZipCode = zipCode;
            TobaccoUsage = tobaccoUsage;
            WellnessFactor = wellnessFactor;
            MedicalClass = medicalClass;
            MedicalClassDisplay = medicalClassDisplay;
            DentalClass = dentalClass;
            DentalClassDisplay = dentalClassDisplay;
            listChild = new List<Child>();
        }
    }
     
    public partial class _Default : System.Web.UI.Page
    {
        List<ParentChild> listParentChild = new List<ParentChild>();
        Dictionary<string, string> medicalDentalClass = new Dictionary<string, string>()
        {
           {"None","None"},
           {"INDIV","Individual Only"},
           {"INDIVS","Employee and Spouse"},
           {"INDIV1","Employee and 1 Child"},
           {"INDIVC","Employee and Children"},
           {"FAMILY","Full Family"},
        };
 
        private void CreateSampleData()
        {
            for (int i = 1; i <= 3; i++)
            {
                ParentChild parentChild = new ParentChild(i, "ParentName" + i, DateTime.Now, "02421", "No","Excellent","INDIV", "Individual Only", "INDIV", "Individual Only");
                for (int j = 1; j <= 2; j++)
                {
                    Child child = new Child(j, DateTime.Now, "No","VeryGood");
                    parentChild.listChild.Add(child);
                }
                listParentChild.Add(parentChild);
                //listParentChild.Add(i.ToString(), parentChild);
            }
        }
 
        private int CreateNewParentId()
        {
            if (listParentChild.Count == 0)
                return 1;
            else
            {
                var maxQuery = (from pc in listParentChild
                                 select pc.ID).Max();
                return maxQuery + 1;
                //return listParentChild[listParentChild.Count - 1].ID + 1;
            }
        }
 
        private int CreateNewChildId(int parentId)
        {
            ParentChild parentChild = listParentChild.Where(item => item.ID == parentId).Single();
            if (parentChild.listChild.Count == 0)
                return 1;
            else
            {
                var maxQuery = (from c in parentChild.listChild
                                select c.ID).Max();
                return maxQuery + 1;
                //return parentChild.listChild[parentChild.listChild.Count - 1].ID + 1;
            }
        }
 
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                CreateSampleData();
                ViewState["listParentChild"] = listParentChild;
            }
            else
            {
                listParentChild = (List<ParentChild>)ViewState["listParentChild"];
            }
        }
 
        protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            var query = from item in listParentChild
                        select new { ID = item.ID,
                                     DOB = item.DOB,
                                     ZipCode = item.ZipCode,
                                     TobaccoUsage = item.TobaccoUsage,
                                     WellnessFactor = item.WellnessFactor,
                                     MedicalClass = item.MedicalClass,
                                     MedicalClassDisplay = item.MedicalClassDisplay,
                                     DentalClass = item.DentalClass,
                                     DentalClassDisplay = item.DentalClassDisplay,
                                     Name = item.Name
                        };
 
            RadGrid1.DataSource = query.ToArray();
        }
 
        protected void RadGrid1_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
        {
            GridDataItem parentItem = e.DetailTableView.ParentItem as GridDataItem;
 
            string parentID = e.DetailTableView.ParentItem.GetDataKeyValue("ID").ToString();
 
            ParentChild parentChild = listParentChild.Where(item => item.ID == Convert.ToInt32(parentID)).Single();
            var query = from item in parentChild.listChild
                        select new { ID = item.ID,
                                        DependentDOB = item.DependentDOB,
                                        DependentTobaccoUsage = item.DependentTobaccoUsage,
                                        DependentWellnessFactor = item.DependentWellnessFactor
                                    };
 
            e.DetailTableView.DataSource = query.ToArray();
        }
 
        protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
        {
            GridEditableItem item = e.Item as GridEditableItem;
            
            if (e.Item.OwnerTableView.Name == "Parent")
            {
 
                int id = CreateNewParentId();
                RadDatePicker picker = (item["DOB"].Controls[0] as RadDatePicker);
                string DOB = picker.SelectedDate != null ? picker.SelectedDate.Value.ToString() : "";
 
                string zipCode = (item["ZipCode"].Controls[0] as TextBox).Text;
 
                GridEditFormItem editFormItem = (GridEditFormItem)e.Item;
                RadComboBox tobaccoUsageCombo = (RadComboBox)editFormItem.FindControl("TobaccoUsageComboBox");
                RadComboBox wellnessFactorCombo = (RadComboBox)editFormItem.FindControl("WellnessFactorComboBox");
                RadComboBox medicalCombo = (RadComboBox)editFormItem.FindControl("MedicalClassComboBox");
                RadComboBox dentalCombo = (RadComboBox)editFormItem.FindControl("DentalClassComboBox");
                ParentChild parentChild = new ParentChild(id, "name", Convert.ToDateTime(DOB), zipCode,
                    tobaccoUsageCombo.SelectedValue,wellnessFactorCombo.SelectedValue,
                    medicalCombo.SelectedValue, medicalDentalClass[medicalCombo.SelectedValue],
                    dentalCombo.SelectedValue, medicalDentalClass[dentalCombo.SelectedValue]
                    );
 
                listParentChild.Add(parentChild);
            }
            else if (e.Item.OwnerTableView.Name == "Child")
            {
                string parentID = e.Item.OwnerTableView.ParentItem.GetDataKeyValue("ID").ToString();
                RadDatePicker picker = (item["DependentDOB"].Controls[0] as RadDatePicker);
                string DOB = picker.SelectedDate != null ? picker.SelectedDate.Value.ToString() : "";
                GridEditFormItem editFormItem = (GridEditFormItem)e.Item;
                RadComboBox tobaccoUsageCombo = (RadComboBox)editFormItem.FindControl("DependentTobaccoUsageComboBox");
                RadComboBox wellnessFactorCombo = (RadComboBox)editFormItem.FindControl("DependentWellnessFactorComboBox");
                int id = CreateNewChildId(Convert.ToInt32(parentID));
 
                Child child = new Child(id, Convert.ToDateTime(DOB),
                                    tobaccoUsageCombo.SelectedValue, wellnessFactorCombo.SelectedValue);
 
                ParentChild parentChild = listParentChild.Where(pc => pc.ID == Convert.ToInt32(parentID)).Single();
                parentChild.listChild.Add(child);
            }
            ViewState["listParentChild"] = listParentChild;
        }
 
        protected void RadGrid1_EditCommand(object sender, GridCommandEventArgs e)
        {
            //// ******* need to close any outstanding Add form ************
            //RadGrid1.MasterTableView.IsItemInserted = false;
 
            //if (e.Item.OwnerTableView.Name == "Child")
            //{
            //    //e.Item.OwnerTableView.ParentItem.RemoveChildEditItems();
            //    e.Item.RemoveChildEditItems();
            //    //RadGrid1.MasterTableView.IsItemInserted = false;
            //}
 
            //e.Item.OwnerTableView.IsItemInserted = false;
 
            //RadGrid1.MasterTableView.ClearEditItems();
        }
 
        protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
        {
            GridEditableItem item = e.Item as GridEditableItem;
            string strId = item.GetDataKeyValue("ID").ToString();
            if (e.Item.OwnerTableView.Name == "Parent")
            {
                RadDatePicker picker = (item["DOB"].Controls[0] as RadDatePicker);            
                string DOB = picker.SelectedDate != null ? picker.SelectedDate.Value.ToString() : "";
 
                string zipCode = (item["ZipCode"].Controls[0] as TextBox).Text;
 
                GridEditFormItem editFormItem = (GridEditFormItem)e.Item;
                RadComboBox tobaccoUsageCombo = (RadComboBox)editFormItem.FindControl("TobaccoUsageComboBox");
                RadComboBox wellnessFactorCombo = (RadComboBox)editFormItem.FindControl("WellnessFactorComboBox");
                RadComboBox medicalCombo = (RadComboBox)editFormItem.FindControl("MedicalClassComboBox");
                RadComboBox dentalCombo = (RadComboBox)editFormItem.FindControl("DentalClassComboBox");
 
                ParentChild parentChild = listParentChild.Where(pc => pc.ID == Convert.ToInt32(strId)).Single();
                parentChild.DOB = Convert.ToDateTime(DOB);
                parentChild.ZipCode = zipCode;
                parentChild.TobaccoUsage = tobaccoUsageCombo.SelectedValue;
                parentChild.WellnessFactor = wellnessFactorCombo.SelectedValue;
                parentChild.MedicalClass = medicalCombo.SelectedValue;
                parentChild.MedicalClassDisplay = medicalDentalClass[medicalCombo.SelectedValue];
                parentChild.DentalClass = dentalCombo.SelectedValue;
                parentChild.DentalClassDisplay = medicalDentalClass[dentalCombo.SelectedValue];
            }
            else if (e.Item.OwnerTableView.Name == "Child")
            {
                string parentID = e.Item.OwnerTableView.ParentItem.GetDataKeyValue("ID").ToString();
                RadDatePicker picker = (item["DependentDOB"].Controls[0] as RadDatePicker);
                string DOB = picker.SelectedDate != null ? picker.SelectedDate.Value.ToString() : "";
                GridEditFormItem editFormItem = (GridEditFormItem)e.Item;
                RadComboBox tobaccoUsageCombo = (RadComboBox)editFormItem.FindControl("DependentTobaccoUsageComboBox");
                RadComboBox wellnessFactorCombo = (RadComboBox)editFormItem.FindControl("DependentWellnessFactorComboBox");
                 
                ParentChild parentChild = listParentChild.Where(pc => pc.ID == Convert.ToInt32(parentID)).Single();
                Child child = parentChild.listChild.Where(c => c.ID == Convert.ToInt32(strId)).Single();
                child.DependentDOB = Convert.ToDateTime(DOB);
                child.DependentTobaccoUsage = tobaccoUsageCombo.SelectedValue;
                child.DependentWellnessFactor = wellnessFactorCombo.SelectedValue;
            }
            ViewState["listParentChild"] = listParentChild;
        }
 
        protected void RadGrid1_DeleteCommand(object sender, GridCommandEventArgs e)
        {
            GridDataItem item = e.Item as GridDataItem;
            string strId = item.GetDataKeyValue("ID").ToString();
 
            if (e.Item.OwnerTableView.Name == "Parent")
            {
                ParentChild parentChild = listParentChild.Where(pc => pc.ID == Convert.ToInt32(strId)).Single();
                listParentChild.Remove(parentChild);
            }
            else if (e.Item.OwnerTableView.Name == "Child")
            {
                string parentID = e.Item.OwnerTableView.ParentItem.GetDataKeyValue("ID").ToString();
                ParentChild parentChild = listParentChild.Where(pc => pc.ID == Convert.ToInt32(parentID)).Single();
                Child child = parentChild.listChild.Where(c => c.ID == Convert.ToInt32(strId)).Single();
                parentChild.listChild.Remove(child);              
            }
            ViewState["listParentChild"] = listParentChild;
        }
 
        protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        {
            GridEditableItem item = e.Item as GridEditableItem;
 
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                if (e.Item.OwnerTableView.Name == "Parent")
                {
                    RegularExpressionValidator regValidator = new RegularExpressionValidator();
                    regValidator.ID = "regValidator";
                    regValidator.ControlToValidate = (item["ZipCode"].Controls[0] as TextBox).ID;
                    regValidator.ValidationExpression = @"\d{5}";
                    regValidator.ErrorMessage = "*ZIP code must be 5 numeric digit";
                    regValidator.ForeColor = System.Drawing.Color.Red;
                    item["ZipCode"].Controls.Add(regValidator);
                }
                else if (e.Item.OwnerTableView.Name == "Child")
                {
                }
            }
        }
 
        protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {
            //if (e.CommandName == "InitInsert")
            //{
            //    // ******* need to close any outstanding Add form ************
            //    //RadGrid1.MasterTableView.IsItemInserted = false;
 
            //    RadGrid1.MasterTableView.ClearEditItems();
            //    if (e.Item.OwnerTableView.Name == "Child")
            //    {
            //        e.Item.OwnerTableView.ParentItem.RemoveChildEditItems();
            //        //RadGrid1.MasterTableView.IsItemInserted = false;
            //    }
            //}
        }
 
 
        protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
            {
                //Clear and reset all outstanding edit form
                e.Item.OwnerTableView.IsItemInserted = false;
                e.Item.OwnerTableView.ClearEditItems();
                e.Item.OwnerTableView.ClearChildEditItems();
                 
                GridEditableItem item = e.Item as GridEditableItem;
                if (e.Item.OwnerTableView.Name == "Parent")
                {
                    RadDatePicker picker = (item["DOB"].Controls[0] as RadDatePicker);
                    picker.MaxDate = DateTime.Now;
 
                    if (item.ItemIndex != -1)
                    {
                        GridEditFormItem editFormItem = (GridEditFormItem)e.Item;
                        RadComboBox tobaccoUsageCombo = (RadComboBox)editFormItem.FindControl("TobaccoUsageComboBox");
                        RadComboBox wellnessFactorCombo = (RadComboBox)editFormItem.FindControl("WellnessFactorComboBox");
                        RadComboBox medicalCombo = (RadComboBox)editFormItem.FindControl("MedicalClassComboBox");
                        RadComboBox dentalCombo = (RadComboBox)editFormItem.FindControl("DentalClassComboBox");
 
                        if (item.GetDataKeyValue("TobaccoUsage") != null)
                            tobaccoUsageCombo.SelectedValue = item.GetDataKeyValue("TobaccoUsage").ToString();
                        if (item.GetDataKeyValue("WellnessFactor") != null)
                            wellnessFactorCombo.SelectedValue = item.GetDataKeyValue("WellnessFactor").ToString();
                        if (item.GetDataKeyValue("MedicalClass") != null)
                            medicalCombo.SelectedValue = item.GetDataKeyValue("MedicalClass").ToString();
                        if (item.GetDataKeyValue("DentalClass") != null)
                            dentalCombo.SelectedValue = item.GetDataKeyValue("DentalClass").ToString();
                    }
                }
                else if (e.Item.OwnerTableView.Name == "Child")
                {
                    RadDatePicker picker = (item["DependentDOB"].Controls[0] as RadDatePicker);
                    picker.MaxDate = DateTime.Now;
 
                    if (item.ItemIndex != -1)
                    {
                        GridEditFormItem editFormItem = (GridEditFormItem)e.Item;
                        RadComboBox tobaccoUsageCombo = (RadComboBox)editFormItem.FindControl("DependentTobaccoUsageComboBox");
                        RadComboBox wellnessFactorCombo = (RadComboBox)editFormItem.FindControl("DependentWellnessFactorComboBox");
 
                        if (item.GetDataKeyValue("DependentTobaccoUsage") != null)
                            tobaccoUsageCombo.SelectedValue = item.GetDataKeyValue("DependentTobaccoUsage").ToString();
                        if (item.GetDataKeyValue("DependentWellnessFactor") != null)
                            wellnessFactorCombo.SelectedValue = item.GetDataKeyValue("DependentWellnessFactor").ToString();
                    }
                }
            }
        }
    }
}

Here is the designer.cs file

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
 
namespace TestWebTelerik {
     
     
    public partial class _Default {
         
        /// <summary>
        /// RadScriptManager1 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::Telerik.Web.UI.RadScriptManager RadScriptManager1;
         
        /// <summary>
        /// RadAjaxManager1 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::Telerik.Web.UI.RadAjaxManager RadAjaxManager1;
         
        /// <summary>
        /// RadAjaxPanel1 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::Telerik.Web.UI.RadAjaxPanel RadAjaxPanel1;
         
        /// <summary>
        /// RadGrid1 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::Telerik.Web.UI.RadGrid RadGrid1;
    }
}
Marin
Telerik team
 answered on 06 Aug 2013
1 answer
69 views
Team,

I am trying to add silverlight control in radtooltip.
But I am getting the blank tooltip. Same Silverlight control is getting display properly out side the radtooltip.

Here is my code 
<telerik:RadToolTip ID="ttTest" runat="server" IsClientID="true" RelativeTo="Element" TargetControlID="Test" ManualClose="true">
    <div id="dvTest"> </div>
    <table border="1">
    <tr>
    <td>  <div id="dvDashboard" clientidmode="Static" runat="server" style="
                            width: 500px; height: 500px">
     <asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/Dashboard.xap"
                                Windowless="true" Width="100%" Height="100%" InitParameters="KPIID=10004,VIEW=Dashboard" />
                                </div>
    </td>
    </tr>
    </table>
      
    </telerik:RadToolTip>

Please let me know what should I do to show silverlight control in radtooltip control.
Thanks
Sampada
Marin Bratanov
Telerik team
 answered on 06 Aug 2013
2 answers
139 views


Private
Sub fetchAutoBoxItems(ByVal sender As Object, ByVal e As AutoCompleteBoxDataSourceSelectEventArgs)
 
      ' Dim source As SqlDataSource = DirectCast(e.DataSource, SqlDataSource)
      'Dim autoCompleteBox As RadAutoCompleteBox = DirectCast(sender, RadAutoCompleteBox)
 
      Dim filterstring As String = e.FilterString
 
      sqlDS.SelectCommandType = SqlDataSourceCommandType.StoredProcedure
      sqlDS.SelectCommand = "my_db.dbo.my_SP"
 
      sqlDS.SelectParameters("SearchTerm").DefaultValue = filterstring
 
  End Sub
 
 
  Private Sub BuildMenuBar()
 
 
      Dim radAutoBox = New RadAutoCompleteBox
      radAutoBox.InputType = RadAutoCompleteInputType.Text
      radAutoBox.TextSettings.SelectionMode = RadAutoCompleteSelectionMode.Single
      radAutoBox.ID = "radAutoBox"
      AddHandler radAutoBox.DataSourceSelect, AddressOf fetchAutoBoxItems
      radAutoBox.Filter = RadAutoCompleteFilter.StartsWith
      radAutoBox.DataSource = sqlDS
       
      sqlDS.SelectParameters("userid").DefaultValue = CStr(_securityContext.UserID)
      sqlDS.SelectParameters("divisionid").DefaultValue = CStr(_securityContext.DivisionId)
 
 
      radAutoBox.DataTextField = "StockSizeGroupName"
      radAutoBox.DataValueField = "StockSizeGroupID"
 
      Master.Menubar.Add(radAutoBox)
<asp:SqlDataSource runat="server" ID="sqlDS" ConnectionString="<%$ ConnectionStrings:DefaultSqlConnection%>" >
      <SelectParameters>
          <asp:Parameter DbType="Int32" Name="userid"   />
          <asp:Parameter DbType="Int32" Name="divisionid"  />
          <asp:Parameter DbType="String" Name="SearchTerm" />
      </SelectParameters>       
  </asp:SqlDataSource>


I am able to get the AutoCompleteBox to work nicely with the above code, but what i wish to do, though, is have the AutoComplete List appear in a GridView/DataGrid instead of the dropdownlist of the AutoCompleteBox.
Is this possible? I am unable to get my GridView to share the same SqlDataSource Control due to the GridView never showing so i'm sure its not binding properly.



<asp:GridView ID="gvAutoBox" runat="server">
     <Columns>
         <asp:BoundField DataField="StockSizeGroupName" />
         <asp:BoundField DataField="StockSizeGroupID" />
         <asp:BoundField DataField="StockSizeName" />
     </Columns>
 </asp:GridView>

'add the following two lines below the ' Master.Menubar.Add(radAutoBox)' line in the 'BuildMenuBar' method
 
        gvAutoBox.DataSource = sqlDS
        gvAutoBox.DataBind()


the BuildMenuBar Method is being called from the Page_Load Event
David
Top achievements
Rank 1
 answered on 06 Aug 2013
1 answer
39 views
Hi Team,

I need a help on Telerik Gird for which I am facing a issue with Collapsing functionality. In the grid there are several Hierarchy groups with row items under each of the them.
When I try to collapse a group, it will end up hiding a bunch of the rows, not just the selected group. 

I encountered this problem when I modified the below mentioned code used in the Telerik grid.

Radgrid.Skin="";

I am using this code in Code behind, I don't want the skin, so I made the above code to take value as empty. This affects the group collapse functionality. I have attached the screenshot which displays the issue.

Note: I am implementing this control in SharePoint 2010

Please suggest me a solution ASAP. Its very urgent.

 Thanks
-Vasanth
Tsvetoslav
Telerik team
 answered on 06 Aug 2013
1 answer
83 views
I like the features of the radtooltip as it makes it quite easy to use.  However I am curious if I can't specify the location of where the tool tip will display the help. 

So when the user sets the focus onto the 1st form item the tooltip will actually be placed in the spot that reads "HELP WILL GO HERE".  This will allow me to setup my forms all the same and the end user will know where to find help.  How might I do this?

<table>
    <tr>
        <td colspan="2" rowspan="2" valign="top">
            HELP WILL GO HERE
            <telerik:RadToolTipManager
                ID="RadToolTipManager1" runat="server" Overlay="True" OnClientShow="OnClientShow" ShowEvent="OnFocus"
                <TargetControls>
                    <telerik:ToolTipTargetControl TargetControlID="_682" />
                    <telerik:ToolTipTargetControl TargetControlID="_684" />
                    <telerik:ToolTipTargetControl TargetControlID="_686" />
                    <telerik:ToolTipTargetControl TargetControlID="_687" />
                    <telerik:ToolTipTargetControl TargetControlID="_688" />
                </TargetControls>
            </telerik:RadToolTipManager>
        </td>
</tr>
    <tr>
        <td>Number of Credit Unions:</td>
        <td>
            <telerik:RadNumericTextBox ID="_682" Runat="server"
                ToolTip="Enter Number of Branches within your Credit Union."
                CssClass="InputTextFF" Width="60px" Culture="en-US"
                DataType="System.Single" DbValueFactor="1" LabelWidth="24px" MaxValue="10000"
                MinValue="0" Value="0">
<NumberFormat ZeroPattern="n" DecimalDigits="0"></NumberFormat>
            </telerik:RadNumericTextBox>
        </td>
        <td>682</td>
    </tr>
</table>
Marin Bratanov
Telerik team
 answered on 06 Aug 2013
1 answer
130 views
Hai Everyone,
  I have a problem in radcombobox.First i add the value in db whatever enter in combobox,then i click again same page i see the what value lastly enter in comobox .I need to remove lastly enter value in comobox.it behave like remember username and password.After logout it goes to login page and can see username and password enter in textbox,bcz we check remember password at first login.
here i attach the screen shot.  
in no.1 ,i enter value in comobox and save in db.
    no.2.if i click same page i clear the value of comobox in javascript and verify there is no value,but
    no 3.i see the lastly enter value in comobox.
So pls reply me how clear lastly enter value ? or in page load i need add some text like "--SELECT--" ?

Regards
  Aravind
Shinu
Top achievements
Rank 2
 answered on 06 Aug 2013
1 answer
68 views
Greetings Telerik Team,

I am using the latest release of the ASP.NET AJAX Q2 2013. Since the upgrade, i have been having an issue with the RadEditor Toolbar. I have built an application that utilizes multiple RadEditors with Docked Toolbars. Each toolbar has a dedicated <DIV> container. On each editor click (when user clicks in each editor, the respective docked toolbar is shown and the others are hidden).

This is working great and is still working from a functionality standpoint, but since the update the Docked Toolbar is rendered incompletely, meaning that the icons show but the background skin graphics are missing except for the end caps and the separators for each editor tool group. I have attached a screenshot of this. The toolbar buttons still work but the user cannot tell if a certain style is active (like bold etc) because the buttons will not show (the background shows through).

I am using the built in Windows7 skin. I tried it also with the Default skin with the same results.

Any assistance would be appreciated. We are close to launching this application, but we cannot do this until it is fixed.

Thanks in advance!
Marin Bratanov
Telerik team
 answered on 06 Aug 2013
1 answer
140 views
Hi Team,

  How can I create Ranges for any value from code behind?

  I have Max Sales Total and Sales Person Sales Total. I have to create Ranges depending on the Total  Max Sales (Which always comes different as per date range). So for example, Total Max Sales is 56k, then I would like to show 60k as the last Range and Ranges will be
From="20000" To="30000"
From="30000" To="40000"
From="40000" To="50000"
From="50000" To="60000"

 If you have any other logic, Please suggest me.

Thanks
Marin Bratanov
Telerik team
 answered on 06 Aug 2013
2 answers
145 views
Hello everyone,
I'm a newbie using RadDocks controls and I'm facing a problem. In fact, I have a panel in my main page, which contains a RadDockLayout, with a RadDockZone and a RadDock inside. However, whatever the width of the RadDockZone, it will always seems to create this huge left margin inside the panel. As you may guess it is very unconvenient and I couldn't find any way to solve it, even with css.
I joined two pictures to illustrate; the red border corresponds to the panel, and the dashed purple one to the RadDockZone. The first one is a 300px wide RadDockZone, and the second one a 600px wide one.
This issue may be trivial but if you have any idea or solution please feel free.
Regards,

Elisa.
Elisa
Top achievements
Rank 1
 answered on 06 Aug 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?