Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
150 views
I'd like to nest a RadListBox in my RadGrid.  How can I link the parent RadGrid to the child RadListBox.  I tried using the "ParentTableRelation" code from below, but its not working.

<ParentTableRelation> 
     <telerik:GridRelationFields DetailKeyField="SEQN" MasterKeyField="SEQN" /> 
</ParentTableRelation> 

Is this something that needs to be done in the code-behind?

J
Sebastian
Telerik team
 answered on 29 Apr 2010
1 answer
122 views

I'm creating a new web application with Entity Framework. I want to use the following layered structure:

User Interface Layer

Business Object Layer

Interface

Entity Framework Layer

The Business Object Layer now implements the interface on bottom layer using the Entity Framework Objects.

In the user interface I use a Telerik component (radGrid) to show/edit/update/delete data. Now I can show entity data to user simply doing a simple (linq to entities) query like:

 var stabilimenti = from s in entities.Stabilimenti
                               select s;

My problem is to persist data on database when user changes them.

In my user page i want to catch the "RadGrid1_UpdateCommand" and in some way persist data modification. Debugging i've seen that at the update event i've lost all data modification (the program executes a Page_Load just before).

How can I persist modification? Have I to use an Entity DataSource and manually place there datas retrieved from Entity Framework entities? Or what else should I do?

Tsvetoslav
Telerik team
 answered on 29 Apr 2010
11 answers
1.0K+ views

 

Hi,

I am trying create a RadGrid by using clientside databinding feature.
My requirement
1. To display first few columns with the data retreived from database using the GridBoundColumn
2. The last 2 column should have "Select" and "Delete" hyperlink. On clicking this hyperlink i need to call the javascript to do some action in the client side. Also the javascript should have a knowledge on which row i clicked.

The problem i am facing
1. I tried with the GridClientSelectColumn but the problem is, RadGrid display only checkbox eventhough i set the ButtonType="LinkButton". I don't know how to display the "Select" text. I was expecting it to show the "Select" text by default or atleast to display the text defined in the "Text" attribute.
2. GridClientDeleteColumn displays the "Delete" link but i am not able to bind the column value to the CommandArgument so that i can know which row is clicked.
3. Also in both the option when i databind the Grid in the client side, both the column doesn't display the text. It first apears and then disapears after the client databind.
4. So I tried with the GridTemplateColumn with the html control in the ItemTemplate but I am not able to bind the data using 
        <telerik:GridTemplateColumn>
               <ItemTemplate>
                      <a href=javascript:rowSelected('<%# Eval("Text") %>') >Select</a> 
                </ItemTemplate>
         </telerik:GridTemplateColumn>
binder, because the data is not displayed.

Could you please let me know some solution or show some pointer to some sample for the following,
1. I want to display a grid with client side databinding with last 2 columns "Select" and "Delete" link button and on clicking this link i should call the javascript with the row information passed to the method.

Thank you for your support.
Sundar

Nikolay Rusev
Telerik team
 answered on 29 Apr 2010
1 answer
85 views
hi guys

i have radgrid and in it i have just 1 column that format is  telerik:GridTemplateColumn.
now i want to add Sort By Price and sort By Name to this column

how i can do that?

tnx

here is my grid code

 <telerik:GridTemplateColumn UniqueName="column1" 
               AllowFiltering="false"  ShowSortIcon="false"   
                Groupable="false"     
                ItemStyle-Font-Names="tahoma" ItemStyle-Font-Size="8"    
                HeaderStyle-Font-Size="8" HeaderStyle-Font-Names="tahoma">  
              <ItemTemplate> 
              <table cellpadding="0" cellspacing="0"  width="100%" style="border-style: none; border-width: 0px;margin:0px;padding:0px" border="0"   
                      ID="tblProductContent" runat="server">  
              <tr > 
              <td style="width:105px" valign="top">  
               <asp:Image  
                  ImageUrl='<%# Eval("PicPath") %>' 
                  Width="100px" Height="100px" 
                   ID="imgProduct" runat="server" /> 
                     
              </td> 
 
              <td> 
                <table cellpadding="0" cellspacing="0"  width="100%" style="border-style: none; border-width: 0px;margin:0px;padding:0px" border="0"   
                <tr> 
                    <tr> 
                        <td valign="top">  
                            <asp:Label ID="Label1" runat="server" Font-Size="10"   
                                Text='<%# Eval("Title") %>'></asp:Label> 
                            <br /> 
                            <br /> 
                        </td> 
                    </tr> 
                    <tr> 
                        <td valign="top">  
                            <div style="margin: 5px;padding:5px; background-color: #F8F8F8; border: 1px solid #DADADA;width:470px">  
                                <asp:Label ID="Label2" runat="server" Font-Size="8" ForeColor="#666666"   
                                    Text='<%# Eval("Des") %>'></asp:Label> 
                                <br /> 
                                <br /> 
                                <div ID="moreInfo" onclick='<%# "openWin("+Eval("ProductID")+")"%>'   
                                    style="cursor:pointer;color:Blue">  
                                    <asp:Label ID="Label3" runat="server"   
                                        Text="<%$ Resources:Resource, MoreInfo %>"></asp:Label> 
                                </div> 
                                <br /> 
                            </div> 
                        </td> 
                    </tr> 
                    <tr> 
                        <td valign="top">  
                            <asp:Label ID="Label5" runat="server" ForeColor="Red"   
                                Text="<%$ Resources:Resource, Price %>"></asp:Label> 
                            <asp:Label ID="Label4" runat="server" Font-Size="7pt" ForeColor="Red"   
                                Text='<%# Eval("Cost") %>'></asp:Label> 
                            <br /> 
                        </td> 
                    </tr> 
                    <tr> 
                        <td valign="top">  
                            <table> 
                                <tr> 
                                    <td> 
                                        <telerik:RadNumericTextBox ID="txtCount" runat="server"   
                                            EmptyMessage="<%$ Resources:Resource, Count %>"   
                                            EmptyMessageStyle-HorizontalAlign="Center" Font-Names="tahoma" Font-Size="8"   
                                            HoveredStyle-HorizontalAlign="Center" InvalidStyleDuration="100"   
                                            MaxValue="32760" MinValue="0" NegativeStyle-HorizontalAlign="NotSet"   
                                            ShowSpinButtons="True" Skin="Office2007" Type="Number" Width="80px">  
                                            <FocusedStyle HorizontalAlign="Center" /> 
                                            <HoveredStyle HorizontalAlign="Center" /> 
                                            <EmptyMessageStyle HorizontalAlign="Center" /> 
                                            <NegativeStyle HorizontalAlign="Center" /> 
                                            <EnabledStyle HorizontalAlign="Center" /> 
                                            <NumberFormat AllowRounding="True" DecimalDigits="0"   
                                                KeepNotRoundedValue="False" /> 
                                        </telerik:RadNumericTextBox> 
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"   
                                            ControlToValidate="txtCount" ErrorMessage="*"   
                                            ValidationGroup='<%# Eval("ProductID") %>'></asp:RequiredFieldValidator> 
                                    </td> 
                                    <td> 
                                        <asp:Button ID="btnAddToBasket" runat="server"   
                                            CommandArgument='<%# Eval("ProductID") %>' CommandName="AddToBasket"   
                                            Text="<%$ Resources:Resource, AddToBasket %>"   
                                            ValidationGroup='<%# Eval("ProductID") %>' /> 
                                    </td> 
                                </tr> 
                            </table> 
                        </td> 
                    </tr> 
                </tr> 
                   
                </table> 
              </td> 
              </tr> 
              </table> 
               <hr style="size:landscape;width:635px; color: #688CAF; opacity:0.4;filter:alpha(opacity=40)" /> 
 
              </ItemTemplate> 
 
 
 
<HeaderStyle Font-Names="tahoma" Font-Size="8pt" Width="15%"></HeaderStyle> 
<ItemStyle Font-Names="tahoma" Font-Size="8pt" Width="15%"></ItemStyle> 
              </telerik:GridTemplateColumn> 
Princy
Top achievements
Rank 2
 answered on 29 Apr 2010
1 answer
61 views
For instance in the http://demos.telerik.com/aspnet-ajax/treeview/examples/applicationscenarios/directorystructure/defaultcs.aspx,
if you click several times very quickly on the Custom Attributes folder the loading indicator keeps being shown. I'm trying to find a suitable solution for this by using hideLoadingStatus() but it just hides the last Loading indicator that was loaded and the other ones stay there.
Any ideas?
Regards,

Mariano Liceaga
Yana
Telerik team
 answered on 29 Apr 2010
0 answers
143 views

I am planning to construct Radscheduler in the "Class Detail Schedule" section. As you might can see from the code, other control is referencing user control. Is there anyway to build RadScheduler in the page without using user control. how it can be implemented and how to assign the datasource. thanks

 

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using DEET.StudentLearningProfile.CSharp.ClassLibrary;
using DEET.StudentLearningProfile.ViewPresenter.ClassManagement.Views;
using Microsoft.Practices.ObjectBuilder;
using NetTiers.Entities;
using Telerik.Web.UI;
using System.Globalization;
using System.Threading;

public partial class ClassManagement_Classes : Microsoft.Practices.CompositeWeb.Web.UI.Page,
                                             

DEET.StudentLearningProfile.ViewPresenter.ClassManagement.Views.IClasses
{
    #region Private members

    private ClassesPresenter presenter;

    #endregion

    [CreateNew]
    public ClassesPresenter Presenter
    {
        set
        {
           
            this.presenter = value;
            this.presenter.View = this;
        }
    }

    protected override void OnPreRender(EventArgs e)
    {
        //BuildSchedule();
        base.OnPreRender(e);
       
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            this.presenter.OnViewInitialized();
        }
        this.presenter.OnViewLoaded();
        BuildClass();
       
       
    }

    public List<ClassSchedulePeriod> ClassScheduleCollection
    {
        set
        {
            //RadScheduler1.DataSource = value;
        }
    }
    // Build class view regardless whether or not a schedule attached 
    public void BuildClass()
    {
        // Get all the class views associated with a given student ID
        // In here, class IDs will not be duplicated, it is one student ID to many class IDs relationship
        VList<NetTiers.Entities.VwStudentsByClass> data = presenter.GetAllClassesByStudentId();
        NetTiers.Services.SafeNameClassService classService = new NetTiers.Services.SafeNameClassService();

        // Get class IDs
        IList<long> classes = new List<long>();
        foreach (NetTiers.Entities.VwStudentsByClass aClass in data)
        {
            if (!classes.Contains(aClass.ClassId))
            {
                classes.Add(aClass.ClassId);
            }
        }

        Telerik.Web.UI.RadPanelBar panelBar = new Telerik.Web.UI.RadPanelBar();
        panelBar.Skin = "WebBlue";
        panelBar.ID = "panelBar";
        panelBar.Width = Unit.Percentage(97);

        foreach (long classId in classes)
        {
            // Going through one class at each loop

            // It is not necessary to retrieve the rows to tempData based on ClassId
            // Also it is not ncessary to calculate how many student groups a class has
            // However, here, it follows the coding style it already has
            /////////////////////////////////////////////////////////////////////////////////////////////
            VList<NetTiers.Entities.VwStudentsByClass> tempData = data.FindAll("ClassId", classId, true);
            IList<long> groups = new List<long>();

            // Find out how many student groups a class has
            foreach (NetTiers.Entities.VwStudentsByClass aClass in tempData)
            {
                if (!groups.Contains(aClass.StudentGroupId))
                {
                    groups.Add(aClass.StudentGroupId);               
                }
            }

            //
            if (groups.Count > 1)
            tempData = tempData.FindAll("StudentGroupId", groups[0], true);
          

            ////////////////////////////////////////////////////////////////////////////////////////////

 

            SafeNameClass currentClass = classService.GetByClassId(classId);
            classService.DeepLoad(currentClass);

            //modify the class name to set Uppercase letter
            CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
            TextInfo txtInfo = cultureInfo.TextInfo;

            RadPanelItem panelItem = new RadPanelItem(txtInfo.ToUpper(tempData[0].ClassName));
            panelItem.Attributes.CssStyle.Add(HtmlTextWriterStyle.FontWeight, "bold");
            panelItem.Attributes.CssStyle.Add(HtmlTextWriterStyle.FontSize, "12px"); 
           

            // Expand the panel item
            panelItem.Expanded = false;
            panelItem.Value = "panelItem";
           

            System.Drawing.Color background = System.Drawing.Color.FromArgb(150, 120, 230);
           
            RadPanelItem classDetailsPanelItem = new RadPanelItem("Class Details");
            RadPanelItem classAssignmentPanelItem = new RadPanelItem("Class Assignment / Homework");
            RadPanelItem classNoticePanelItem = new RadPanelItem("Class Notices");
            RadPanelItem classSchedulePanelItem = new RadPanelItem("Class Schedule");
            RadPanelItem classDetailSchedulerPanelItem = new RadPanelItem("Class Detail Schedule");

            classDetailSchedulerPanelItem.BackColor = background;
            classDetailsPanelItem.BackColor = background;
            classNoticePanelItem.BackColor = background;
            classAssignmentPanelItem.BackColor = background;
            classSchedulePanelItem.BackColor = background;
            classDetailsPanelItem.Attributes.CssStyle.Add(HtmlTextWriterStyle.FontWeight, "bold");
            classSchedulePanelItem.Value = "template";

            ClassScheduleTemplate classScheduleTemp = new ClassScheduleTemplate();
           

classScheduleTemp.LoadUserControl(this.LoadControl("~/ClassManagement/Controls/StudentViewClassSchedule.ascx"));

            ClassAssignmentTemplate classAssignmentTemp = new ClassAssignmentTemplate();
           

classAssignmentTemp.LoadUserControl(this.LoadControl("~/ClassManagement/Controls/StudentViewClassAssignment.ascx"));

            ClassNoticeTemplate classNoticeTemp = new ClassNoticeTemplate();
           

classNoticeTemp.LoadUserControl(this.LoadControl("~/ClassManagement/Controls/StudentViewClassNotices.ascx"));
           
            //ClassDetailsTemplate classDetailsTemp = new ClassDetailsTemplate();
           

//classDetailsTemp.LoadUserControl(this.LoadControl("~/ClassManagement/Controls/StudentViewClassDetails.ascx"));
            //classDetailsTemp.ClassDetails(currentClass);

            classScheduleTemp.SetScheduleDataSource(presenter.GetClassScheduleByClassId(classId));
            classNoticeTemp.SetNoticesDataSource(presenter.GetClassNoticeByClassId(classId));
            classAssignmentTemp.SetAssignmentDataSource(presenter.GetAssignmentByClassId(classId));
            //this.presenter.GetTimetableDataSource((long)SessionObject.ManagedUserId);

            classAssignmentPanelItem.ItemTemplate = classAssignmentTemp;
            classSchedulePanelItem.ItemTemplate = classScheduleTemp;
            classNoticePanelItem.ItemTemplate = classNoticeTemp;
            //classDetailsPanelItem.ItemTemplate = classDetailsTemp;
            //classDetailSchedulerPanelItem.ItemTemplate = classScedulerViewTemp;

            //panelItem.Items.Add(classDetailsPanelItem);

            panelItem.Items.Add(classSchedulePanelItem);
            panelItem.Items.Add(classNoticePanelItem);
            panelItem.Items.Add(classAssignmentPanelItem);
            panelItem.Items.Add(classDetailSchedulerPanelItem);
            panelBar.Items.Add(panelItem);
        }

        ClassPlaceHolder.Controls.Add(panelBar);

    }

    // Build class view which has at least one schedule attached to it
    public void BuildSchedule()
    {
        // Not every class that a student belongs to has attached schedules.
        // Get all the ClassSchedule views associated with a given student ID
        // One class may have more than one schedule attached to it, so in this case, it considered as two different

views
        VList<NetTiers.Entities.VwStudentClassSchedule> data = presenter.GetClassByStudentId();
        NetTiers.Services.SafeNameClassService classService = new NetTiers.Services.SafeNameClassService();
       
        // Get class IDs, but only those classes have attached schedules
        // One class may have more than one attached schedule, this process will get rid of duplicates class IDs
        IList<long> classes = new List<long>();
        foreach(NetTiers.Entities.VwStudentClassSchedule schedule in data){
            if (!classes.Contains(schedule.ClassId))
            {
                classes.Add(schedule.ClassId);
            }
        }

        Telerik.Web.UI.RadPanelBar panelBar = new Telerik.Web.UI.RadPanelBar();
        panelBar.Skin = "WebBlue";
        panelBar.ID = "panelBar";
        panelBar.Width = Unit.Percentage(97);

        foreach (long classId in classes)
        {
            // Going through one class at each loop
            // In all the ClassSchedule views, extracting out the views associated with only the given class ID in

each loop
            //
            VList<NetTiers.Entities.VwStudentClassSchedule> tempData = data.FindAll("ClassId",classId,true);
            IList<long> groups = new List<long>();

            // Find out how many student groups a class has
            foreach (NetTiers.Entities.VwStudentClassSchedule schedule in tempData)
            {
                if (!groups.Contains(schedule.StudentGroupId))
                {
                    groups.Add(schedule.StudentGroupId);

                }
            }

            // Only get the first student group comes up
            if (groups.Count > 1)
            tempData = tempData.FindAll("StudentGroupId", groups[0], true);
          
            SafeNameClass currentClass = classService.GetByClassId(classId);
            classService.DeepLoad(currentClass);

            RadPanelItem panelItem = new RadPanelItem(tempData[0].ClassName);
           
            panelItem.Expanded = false;
            panelItem.Value = "panelItem";

            //System.Drawing.Color background = System.Drawing.Color.FromArgb(176, 196, 222);
            System.Drawing.Color background = System.Drawing.Color.FromArgb(150, 120, 230);
           
            RadPanelItem classDetailsPanelItem = new RadPanelItem("Class Details");
            RadPanelItem classAssignmentPanelItem = new RadPanelItem("Class Assignment / Homework");
            RadPanelItem classNoticePanelItem = new RadPanelItem("Class Notices");
            RadPanelItem classSchedulePanelItem = new RadPanelItem("Class Schedule");
            RadPanelItem classDetailSchedulerPanelItem = new RadPanelItem("Class Detail Schedule");

            classDetailSchedulerPanelItem.BackColor = background;
            classDetailsPanelItem.BackColor = background;
            classNoticePanelItem.BackColor = background;
            classAssignmentPanelItem.BackColor = background;
            classSchedulePanelItem.BackColor = background;
            classDetailsPanelItem.Attributes.CssStyle.Add(HtmlTextWriterStyle.FontWeight, "bold");
            classSchedulePanelItem.Value = "template";
           
            ClassScheduleTemplate classScheduleTemp = new ClassScheduleTemplate();
           

classScheduleTemp.LoadUserControl(this.LoadControl("~/ClassManagement/Controls/StudentViewClassSchedule.ascx"));

            ClassAssignmentTemplate classAssignmentTemp = new ClassAssignmentTemplate();
           

classAssignmentTemp.LoadUserControl(this.LoadControl("~/ClassManagement/Controls/StudentViewClassAssignment.ascx"));

            ClassNoticeTemplate classNoticeTemp = new ClassNoticeTemplate();
           

classNoticeTemp.LoadUserControl(this.LoadControl("~/ClassManagement/Controls/StudentViewClassNotices.ascx"));

            //ClassDetailsTemplate classDetailsTemp = new ClassDetailsTemplate();
           

//classDetailsTemp.LoadUserControl(this.LoadControl("~/ClassManagement/Controls/StudentViewClassDetails.ascx"));
            //classDetailsTemp.ClassDetails(currentClass);

            //BuildClassScheduler();
           
            classScheduleTemp.SetScheduleDataSource(presenter.GetClassScheduleByClassId(classId));
            classNoticeTemp.SetNoticesDataSource(presenter.GetClassNoticeByClassId(classId));
            classAssignmentTemp.SetAssignmentDataSource(presenter.GetAssignmentByClassId(classId));
            //this.presenter.GetTimetableDataSource((long)SessionObject.ManagedUserId);

            classAssignmentPanelItem.ItemTemplate = classAssignmentTemp;
            classSchedulePanelItem.ItemTemplate = classScheduleTemp;
            classNoticePanelItem.ItemTemplate = classNoticeTemp;
            //classDetailsPanelItem.ItemTemplate = classDetailsTemp;
            //classDetailSchedulerPanelItem.ItemTemplate = classScedulerViewTemp;
            //panelItem.Items.Add(classDetailsPanelItem);
           
            panelItem.Items.Add(classNoticePanelItem);
            panelItem.Items.Add(classSchedulePanelItem);
            panelItem.Items.Add(classAssignmentPanelItem);
            panelItem.Items.Add(classDetailSchedulerPanelItem);

            panelBar.Items.Add(panelItem);
        }

        ClassPlaceHolder.Controls.Add(panelBar);
 
    }

    //public void BuildClassScheduler()
    //{
    //    RadScheduler clsScheduler = new RadScheduler();
    //    clsScheduler.DataSourceID = "";
    //    clsScheduler.DataStartField = "Start";
    //    clsScheduler.DataEndField = "End";
    //    clsScheduler.FirstDayOfWeek = DayOfWeek.Monday;
    //    clsScheduler.LastDayOfWeek = DayOfWeek.Sunday;
    //    clsScheduler.HoursPanelTimeFormat = "htt";
    //    clsScheduler.ValidationGroup="RadScheduler1";
    //    clsScheduler.DataSubjectField = "Subject";
    //    clsScheduler.DataRecurrenceField = "RecurrenceRule";
    //    clsScheduler.DataRecurrenceParentKeyField = "RecurrenceParentID";
    //    clsScheduler.Height = Unit.Pixel(600);
    //    clsScheduler.Width = Unit.Percentage(100);
    //    clsScheduler.SelectedView = SchedulerViewType.WeekView;
    //    clsScheduler.AllowDelete = false;
    //    clsScheduler.AllowEdit = false;
    //    clsScheduler.AllowInsert = false;
      

    //}
}

public class DownloadLinktemplate : ITemplate
{
    HyperLink dwnLink = new HyperLink();

    #region ITemplate Members

    public void InstantiateIn(Control container)
    {
        dwnLink.ID = "downloadLink";
        container.Controls.Add(dwnLink);
    }

    #endregion
}

public class ClassNoticeTemplate : ITemplate
{
    RadGrid noticesGrid = new RadGrid();
    Control c;

    public void InstantiateIn(Control container)
    {
        container.Controls.Add(c);
      
    }

    public void LoadUserControl(Control c)
    {
        this.c = c;
    }

    public void SetNoticesDataSource(TList<NetTiers.Entities.ClassNotice> data)
    {
        ((RadGrid)c.FindControl("ClassNoticeGrid")).ItemDataBound += noticesGrid_ItemDataBound;
        ((RadGrid)c.FindControl("ClassNoticeGrid")).DataSource = data;

    }

    #region Grid Events

    void noticesGrid_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            ClassNotice currentClass = (ClassNotice)e.Item.DataItem;
            //UserInfo currentUser = (UserInfo)Session[EnumSessionVariables.UserInfo.ToString()];

            //bind the client script for launching the download
            if (currentClass.AttachedItem != null)
            {
                ((HyperLink)e.Item.FindControl("downloadLink")).ToolTip = "Download Attached File";
                ((HyperLink)e.Item.FindControl("downloadLink")).NavigateUrl = "filedownload.txt?" +

"tab=Classes&Notice=true&key=" +
                    e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ClassNoticeId"] +
                    "&studentid=" + SessionObject.ManagedUserId + "&Notice=yes";
               
            }
            else
            {
                HyperLink downloadLink = e.Item.FindControl("downloadLink") as HyperLink;
                downloadLink.ImageUrl = "~/RadControls/Grid/Skins/Cancel.gif";
                downloadLink.ToolTip = "No attachment to download";
                downloadLink.Enabled = false;
            }
        }
    }

    #endregion

}

public class ClassAssignmentTemplate : ITemplate
{
    RadGrid assignmentGrid = new RadGrid();
    Control c;

    public void InstantiateIn(Control container)
    {
        container.Controls.Add(c);

    }

    public void LoadUserControl(Control c)
    {
        this.c = c;
    }

    public void SetAssignmentDataSource(TList<NetTiers.Entities.ClassAssignment> data)
    {
        ((RadGrid)c.FindControl("ClassAssignmentGrid")).ItemDataBound += classAssignmentGrid_ItemDataBound;
        ((RadGrid)c.FindControl("ClassAssignmentGrid")).DataSource = data;
    }

    #region Grid Events

    void classAssignmentGrid_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            ClassAssignment currentClass = (ClassAssignment)e.Item.DataItem;
            //UserInfo currentUser = (UserInfo)Session[EnumSessionVariables.UserInfo.ToString()];

            //bind the client script for launching the download
            if (currentClass.Attachment != null)
            {
                ((HyperLink)e.Item.FindControl("downloadLink")).ToolTip = "Download Attached File";
                ((HyperLink)e.Item.FindControl("downloadLink")).NavigateUrl = "filedownload.txt?" +

"tab=Classes&Assignment=true&key=" +
                    e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["AssignmentId"] +
                    "&studentid=" + SessionObject.ManagedUserId;
               
            }
            else
            {
                HyperLink downloadLink = e.Item.FindControl("downloadLink") as HyperLink;
                downloadLink.ImageUrl = "~/RadControls/Grid/Skins/Cancel.gif";
                downloadLink.ToolTip = "No attachment to download";
                downloadLink.Enabled = false;
            }
        }
    }
    #endregion

}

public class ClassScheduleTemplate : ITemplate
{

    #region ITemplate Members
    RadGrid scheduleGrid = new RadGrid();
    Control userControl;

    public void LoadUserControl(Control c)
    {
        userControl = c;
    }

    public void InstantiateIn(Control container)
    {
        container.Controls.Add(userControl);
    }

    public void SetScheduleDataSource(TList<NetTiers.Entities.ClassSchedule> data)
    {
        ((RadGrid)userControl.FindControl("ClassScheduleGrid")).DataSource = data;
        ((RadGrid)userControl.FindControl("ClassScheduleGrid")).ItemDataBound += new

GridItemEventHandler(classScheduleGrid_ItemDataBound);
    }

    void classScheduleGrid_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            ClassSchedule currentClass = (ClassSchedule)e.Item.DataItem;
            //UserInfo currentUser = (UserInfo)Session[EnumSessionVariables.UserInfo.ToString()];

            //bind the client script for launching the download
            if (currentClass.Attachment != null)
            {
                ((HyperLink)e.Item.FindControl("downloadLink")).ToolTip = "Download Attached File";
                ((HyperLink)e.Item.FindControl("downloadLink")).NavigateUrl = "filedownload.txt?" +

"tab=Classes&Schedule=true&key=" +
                    e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ClassTimeId"] +
                    "&studentid=" + SessionObject.ManagedUserId +"&Schedule=yes";

            }
            else
            {
                HyperLink downloadLink = e.Item.FindControl("downloadLink") as HyperLink;
                downloadLink.ImageUrl = "~/RadControls/Grid/Skins/Cancel.gif";
                downloadLink.ToolTip = "No attachment to download";
                downloadLink.Enabled = false;
            }
        }

    }

    #endregion

}

public class ClassDetailsTemplate : ITemplate
{
    TextBox classOwner = new TextBox();
    LinkButton sharedresource = new LinkButton();
    TextBox classDescription = new TextBox();
    Label description = new Label();
    Label owner = new Label();

    Control c;

    public void InstantiateIn(Control container)
    {

        container.Controls.Add(c);

    }

    public void LoadUserControl(Control c)
    {
        this.c = c;
    }

    public void ClassDetails(SafeNameClass currentClass)
    {
        ((TextBox)c.FindControl("txtClassdescription")).Text = currentClass.ClassDescription;
        ((TextBox)c.FindControl("txtClassOwner")).Text = string.Format("{0} {1}",

currentClass.UserCreatedSource.FirstName, currentClass.UserCreatedSource.Surname);
        if (currentClass.ResourceSiteUrl == null)
        {
            ((HyperLink)c.FindControl("resourceSiteLnk")).Visible = false;
        }
        else
        {
            ((HyperLink)c.FindControl("resourceSiteLnk")).NavigateUrl = currentClass.ResourceSiteUrl;
        }
    }

}

 

 

Mark de Torres
Top achievements
Rank 1
 asked on 29 Apr 2010
1 answer
486 views
Hi  folks, this is particularly difficult to explain, however I will try by best
at the moment I have a raddatetimepicker on a page,

I have a pagemethod that accepts  the value of the raddatetimepicker field and saves it to the database.
at present I am in New Zealand and the hosted application is on our server in the UK. if I enter in a date of say 23/apr/2010 13:00 the date is saved on the server as 23/apr/2010 01:00.  which I understand and accept.

However when I go to view the record back on my browser it shows the server time (this is because the date &time is actually bound to the control server side)  . I am sure that if  I save  the record again  that the time on the server will go to 22/apr/20101 13:00

what is the best way to ensure that times are correct,  I believe that using  UTC format may be the best way to go, but as yet I've not seen a good example for how to use this. or do I  supply the current time zone of the client to the  server and do my calculations there?

Many Thanks 

Mark



Radoslav
Telerik team
 answered on 29 Apr 2010
1 answer
124 views
I have attached code and sample output.  I have a binary image control in a column.  I load the control for each row in the grid and it displays correctly.  When I click on a row the corresponding PDF document is displayed correctly. however, the grid looks empty but the contents have actually moved way down the page.  Could you please tell me what I am doing wrong?

Thanks

{
    DocGrid = sender;
}
function DocRowSelected(sender, eventArgs) {
    // alert("Click on row with index: " + rowIndex);
    var MasterTable = DocGrid.get_masterTableView();
    var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
    var path = MasterTable.getCellByColumnUniqueName(row, "DT_FilePath").innerHTML;
    var Filename = MasterTable.getCellByColumnUniqueName(row, "DT_FileName").innerHTML;
    var Pgm
    Pgm = "DisplayDocument.aspx?File=" + path + Filename;
    open(Pgm);

}


<telerik:RadGrid ID="DocGrid" runat="server" AutoGenerateColumns="False"  Visible="False"
    DataSourceID="docDS" Skin="" OnItemDataBound="DocGrid_ItemDataBound" 
    Width="1000px" Height="800px" HorizontalAlign="Center" AllowSorting="True" >
            <ClientSettings >
                <Selecting AllowRowSelect="True"></Selecting>
                <ClientEvents OnRowClick="DocRowSelected" OnGridCreated="DocGridCreated">
                </ClientEvents>
                <Scrolling AllowScroll="True" UseStaticHeaders="True" />
            </ClientSettings>
<MasterTableView DataSourceID="docDS" GridLines="Both">
    <Columns>
        <telerik:GridTemplateColumn UniqueName="imageColumn">
            <ItemTemplate>
                <telerik:RadBinaryImage ID="myPDF" runat="server" Height="260" Width="200" />
            </ItemTemplate>
            <HeaderStyle Width="200px" />
            <ItemStyle Height="260px" Width="200px" />
        </telerik:GridTemplateColumn>
        <telerik:GridBoundColumn DataField="DT_FileNum" Display="False"
            HeaderText="DT_FileNum" SortExpression="DT_FileNum" UniqueName="DT_FileNum">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="DT_Desc" HeaderText="Document"
            SortExpression="DT_Desc" UniqueName="DT_Desc">
            <HeaderStyle Font-Bold="true" Font-Size="Medium" HorizontalAlign="Center"
                Width="400px" />
            <ItemStyle Font-Bold="True" Font-Size="Medium" HorizontalAlign="Left"
                Width="400px" />
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="DT_DateTime"
            DataFormatString="{0:MM/dd/yyyy}" DataType="System.DateTime"
            HeaderText="Create Date" SortExpression="DT_DateTime" UniqueName="DT_DateTime">
            <HeaderStyle Font-Bold="true" Font-Size="Medium" HorizontalAlign="Center"
                Width="150px" />
            <ItemStyle Font-Bold="True" Font-Size="Medium" HorizontalAlign="Center"
                Width="150px" />
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="DT_Clerk" HeaderText="Clerk"
            SortExpression="DT_Clerk" UniqueName="DT_Clerk">
            <HeaderStyle Font-Bold="true" Font-Size="Medium" HorizontalAlign="Center"
                Width="200px" />
            <ItemStyle Font-Bold="True" Font-Size="Medium" HorizontalAlign="Center"
                Width="200px" />
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="DT_FilePath" Display="False"
            HeaderText="DT_FilePath" SortExpression="DT_FilePath" UniqueName="DT_FilePath">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="DT_FileName" Display="False"
            HeaderText="DT_FileName" SortExpression="DT_FileName" UniqueName="DT_FileName">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="DT_DocumentCategory" Display="False"
            HeaderText="Category" SortExpression="DT_DocumentCategory"
            UniqueName="DT_DocumentCategory">
            <HeaderStyle Font-Bold="True" Width="80px" />
            <ItemStyle Font-Size="Small" />
        </telerik:GridBoundColumn>
    </Columns>
</MasterTableView>
  
</telerik:RadGrid>

    Protected Sub DocGrid_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs)
        Dim GridItem As GridDataItem
        Dim myImage As PdfRasterizer
        Dim MyControl As RadBinaryImage
        Dim myImageSize As FixedImageSize = New FixedImageSize(196, 254)
        If Not TypeOf (e.Item) Is GridDataInsertItem Then
            If (TypeOf (e.Item) Is GridDataItem) Then
                Dim databounditem As GridDataItem = e.Item
                GridItem = e.Item
                ceTe.DynamicPDF.Rasterizer.PdfRasterizer.AddLicense("RST10NXDFAAALGWbGdA/Ngn6wTGmkU9PgO+wQPvVJHzsB7defcssnA4G1RG1bjmjlNG8QillITKUiVQt7T27hvFr1kacZA0rklJg")
                Try
                    If Left(databounditem("DT_Desc").Text, 11) = "Unspecified" Then
                        databounditem("DT_Desc").Text = Replace(databounditem("DT_Desc").Text, "Unspecified Service - ", "")
                    End If
                    myImage = New PdfRasterizer(Server.MapPath(BLLayer.ImagingVirtualPath) & "\" & databounditem("DT_FilePath").Text & databounditem("DT_FileName").Text)
                    MyControl = DirectCast(GridItem("imageColumn").FindControl("MyPDF"), RadBinaryImage)
                    MyControl.DataValue = myImage.Pages(0).Draw(ceTe.DynamicPDF.Rasterizer.BmpImageFormat.Bmp, myImageSize)
                Catch ex As Exception
                    If BLLayer.EmailErrors Then
                        BLLayer.MailException(ex, "QueryFinal error on Document tab.")
                    Else
                        Session("EX") = ex.Message
                        Session("EX2") = "QueryFinal error on Document tab."
                        Response.Redirect("ProgramError.aspx")
                    End If
                End Try
            End If
        End If
       
    End Sub
Veli
Telerik team
 answered on 29 Apr 2010
1 answer
71 views
Dear team,

I want to use the form template in radgrid edit mode to include the upload from the GridAttachmentColumn. I am using the form template becaue it gives me more flexibility.  Howver, i tried to use the radupload control but  i did not know how to access the binary data inorder to assign it to a byte field. Can you tell me how to format and place the upload field that is imbedded in the 

GridAttachmentColumn.

Thans in advance
Troy Horsford
troyhorsford@yahoo.com

Veli
Telerik team
 answered on 29 Apr 2010
1 answer
452 views
i wanto true ISInEditMode property of RadGrid But Its Give Below message.

Property or indexer 'Telerik.Web.UI.GridItem.IsInEditMode' cannot be assigned to -- it is read only 
Princy
Top achievements
Rank 2
 answered on 29 Apr 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?