Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
179 views
What I'm doing:
1. Put two RadAjaxPanels on a page.
2. Put one Rad controls in one of these panels and a simple asp.net control in the other one.
3. Changes made in one of these panels should refresh another panel but don't touch the panel where is the change was made.
4. Do any action in the panel with RadControl - panel with asp.net control will refresh correctly.
5. Do any change with asp.net control - panel with Rad control will breaks down and doesn't fire any events anymore.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AjaxProject_1.Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title>Default page</title>
</head>
<body>
    <form id="form1" runat="server">
    <tel:RadScriptManager runat="server" ID="Rsm1"></tel:RadScriptManager>
    <tel:RadAjaxManager runat="server" ID="Ram1"></tel:RadAjaxManager>
    <tel:RadScriptBlock runat="server">
        <script language="javascript">
            function __doXBack(args) {
                var ram = $find("<%= Ram1.ClientID %>");
                if (ram) ram.ajaxRequest(args);
            }
 
            function Refresh1(sender, args) {
                var value = args.getDataKeyValue("Id");
                if (value) __doXBack("1|" + value);
            }
 
            function Refresh2(ddl) {
                __doXBack("2|" + ddl.options[ddl.selectedIndex].value);
            }
        </script>
    </tel:RadScriptBlock>
 
    <tel:RadAjaxPanel runat="server" ID="Rap1">
        <asp:DropDownList runat="server" ID="Rcb1" onChange="Refresh2(this)"></asp:DropDownList>
    </tel:RadAjaxPanel>
 
    <hr/>
 
    <tel:RadAjaxPanel runat="server" ID="Rap2">
        <tel:RadGrid runat="server" ID="Grid1">
            <ClientSettings>
                <Selecting AllowRowSelect="True"></Selecting>
                <ClientEvents OnRowSelected="Refresh1"></ClientEvents>
            </ClientSettings>
            <MasterTableView ClientDataKeyNames="Id"></MasterTableView>
        </tel:RadGrid>
    </tel:RadAjaxPanel>
    </form>
</body>
</html>


using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Telerik.Web.UI;
 
namespace AjaxProject_1
{
    public partial class Default : System.Web.UI.Page
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
             Ram1.AjaxRequest += Ram1OnAjaxRequest;
        }
 
        private void Ram1OnAjaxRequest(object sender, AjaxRequestEventArgs e)
        {
            if (e == null || string.IsNullOrEmpty(e.Argument)) return;
             if (e.Argument.StartsWith("1|"))
            {
                InitComboBox(e.Argument);
                Rap1.RaisePostBackEvent(null);
            }
            if (e.Argument.StartsWith("2|"))
            {
                InitGrid();
                Rap2.RaisePostBackEvent(null);
            }
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack) return;
             InitComboBox("0");
            InitGrid();
        }
 
        private void InitComboBox(string id)
        {
            Rcb1.Items.Clear();
             var list = new List<string> {id};
            for (var i = 0; i < 10; i++) list.Add(GetRandomPropertyValue());
            Rcb1.DataSource = list;
            Rcb1.DataBind();
        }
 
        private static readonly IList<string> Properties = new[] {"Id", "Name"};
        private void InitGrid()
        {
            var data = new DataTable();
            Array.ForEach(Properties.ToArray(), t => data.Columns.Add(new DataColumn(t, typeof(string))));
            for (var i = 0; i < 10; i++)
            {
                var row = data.NewRow();
                row["Id"] = i.ToString();
                row["Name"] = GetRandomPropertyValue();
                data.Rows.Add(row);
            }
             Grid1.DataSource = data;
            Grid1.DataBind();
        }
 
        private static IList<char> _chars;
        private static readonly Random Rnd = new Random(DateTime.Now.Millisecond);
        private static string GetRandomPropertyValue()
        {
            if (_chars == null)
            {
                _chars = new List<char> {' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
                for (var c = 'a'; c <= 'z'; c++) _chars.Add(c);
                for (var c = 'A'; c <= 'Z'; c++) _chars.Add(c);
            }
 
            var len = Rnd.Next(10, 15);
            var sb = new StringBuilder();
            for (var i = 0; i < len; i++) sb.Append(_chars[Rnd.Next(0, _chars.Count - 1)]);
            return sb.ToString();
        }
    }
}


I know that I can get that behaviour from page with another methods like AjaxUpdatedControls in AjaxManager and so on, but I need to update panels like I described. It is some kind of specific application and I have to use this way to update controls on page.
Unfortunately it is not working.
Any ideas how to make it working?
Vasil
Telerik team
 answered on 13 Jun 2012
1 answer
44 views

Hi!

I am new to asp, so please excuse me if I don't express myself correctly.

I have a RadScheduler with a Linq data source. I want to get appointments from the database based on a given id.

In my DataClasses.dbml I have four tables and (for now) two stored procedures, GetProgram() and GetProgramById(int id). The user chooses the id from a checkboxlist, and I want to call the GetProgramById(int id) from codebehind. 

In markup I have configured the RadScheduler with DataSourceID="ProgramDataSource". I try to set the data source property to the result of the GetProgramById(int id), but then I get an error saying that both DataSourceID and DataSource properties are set, and that I have to remove one of them. If I remove  DataSourceID="ProgramDataSource" from markup I can set DataSource=GetProgrambyID(int id), but then none of the appointments are updated to the database after closing the AdvancedEdit form of the scheduler.

There must be a way to get a subset of the appointments, and to be able to edit them, so I would be greatful if anyone could help me find it.

Thank you!

Regards, Jill-Connie Lorentsen

protected void RadListBoxTmp_ItemCheck(object sender, RadListBoxItemEventArgs e)
   {
 
       int id;        
       bool result = Int32.TryParse( e.Item.Value, out id);
       if ( e.Item.Checked && result)
       {
           var dataContext = new DataClassesDataContext();
           ProgramDataManager dataManager = 
                   new ProgramDataManager((SqlConnection)dataContext.Connection);
 
           var program = new List<GetProgramByIDResult>();
           program = dataManager.GetProgramByID(id);
 
            
           RadScheduler1.DataSource = program;
           RadScheduler1.Rebind(); 
       }
         
   }
Plamen
Telerik team
 answered on 13 Jun 2012
8 answers
133 views
hai
on postback i wan to show the radslidingpane expanded. but i couldnt find any server side properties for that
is it possible to do this at all
Nicolaï
Top achievements
Rank 2
 answered on 13 Jun 2012
1 answer
431 views
One of the variables in my update queries is the current date.  I don't know how to set it up ride on the sqldatasource.  Using the regular aspx gridview, I normally set this in the code behind.

I'm at a loss on how to do this in radgrid.  Here's the code that I've trying to solve.  Everything else works but when I do the update, it still cannot find this parameter.

I would appreciate the help.  Thank you!

 Protected Sub RadGrid1_UpdateCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand
        SqlDataSource1.UpdateParameters.Add("@InactiveDate", SqlDbType.DateTime)
        SqlDataSource1.UpdateParameters("@InactiveDate").DefaultValue = Date.Now()


    End Sub
Shinu
Top achievements
Rank 2
 answered on 13 Jun 2012
1 answer
66 views
hi,
i am using radgrid with vitualscrolling in my application and i am using client side databinding to avoid postpack .if radgrid contains more than two pages ,radgrid working fine but if radgrid contains two pages, i am unable to view second page..becoz scroll is not working... please give some suggestion.The following codings are using in my application.

javascript:
function RadGrid1_Command(sender, args)
{
args.set_cancel(
true);
var currentPageIndex = sender.get_masterTableView().get_currentPageIndex();
var pageSize = sender.get_masterTableView().get_pageSize();
...........................................
...........................................
..........................................
...........................................
...................
}
function updateGrid(result) {
var tableView = $find(document.getElementById("hdnradgridclientid").value).get_masterTableView();
tableView.set_dataSource(result);
tableView.dataBind();
}
function updateVirtualItemCount(result)
{
var tableView = $find(document.getElementById("hdnradgridclientid").value).get_masterTableView();
tableView.set_virtualItemCount(result);
}       


aspx page:

<telerik:RadGrid ID="RadGridAssessment" EnableViewState="false" Width="100%" runat="server"
 AllowSorting="True" Height="430px" AllowMultiRowSelection="true" AllowPaging="true"GridLines="None" BorderWidth="0" AutoGenerateColumns="true" PagerStyle-AlwaysVisible="false"Skin="Vista" OnNeedDataSource="RadGrid1_NeedDataSource">
<PagerStyle Visible="false" />
<MasterTableView Width="99%">
</MasterTableView>
<ClientSettings EnableRowHoverStyle="true">
<ClientEvents OnCommand="RadGrid1_Command" />
<Selecting AllowRowSelect="True"></Selecting>
<Scrolling AllowScroll="true" EnableVirtualScrollPaging="true" UseStaticHeaders="true"ScrollHeight="275px" SaveScrollPosition="True">
</
Scrolling>
</ClientSettings>
 </telerik:RadGrid>

Prab
Top achievements
Rank 1
 answered on 13 Jun 2012
0 answers
64 views
the following thread started this discussion http://www.telerik.com/community/forums/aspnet-ajax/grid/getting-value-from-griddropdowncolumn-when-not-in-edit-mode.aspx about retrieving ListValueField of a cell when in display mode. At the time, it was not possible to do so directly. Have you made any changes in this regard enabling such retrieval? If not, i would like to propose this as a feature enhancement.

from my point of view - and no offense - it is a complete crock to make another trip to the database when the data has already once been retrieved.

to be more specific, i have the GridDataItem form of the data - i even have full access to the grid - and would like to retrieve the ListValueField - not the ListTextField value which is quite simple to access.
tony
Top achievements
Rank 1
 asked on 13 Jun 2012
1 answer
152 views
Hi telerik team,

Are there any approaches for this case?

Thanks so much!
Shinu
Top achievements
Rank 2
 answered on 13 Jun 2012
2 answers
112 views
Hi Telerik,

I have a dynamically created floating RadDock called "FormAreaDock" that I use to act like a box - sort of a placeholder - for other dynamically floating RadDocks.

I am purposely not using RadDockZones because as far as I know, zones cannot be moved anywhere I want to move it.

I have been able to move the "FormAreaDock" to virtually any position and any other floating RadDocks that are within the bounds of the "FormAreaDock" also move along with it.

My problem is that it only works when I'm running the program in my development machine. Once I publish (deploy) it, it refuses to work as it should and I am getting the following error message:

Webpage error details
  
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; InfoPath.2; .NET4.0C; .NET4.0E)
Timestamp: Thu, 7 Jun 2012 23:19:50 UTC
  
  
Message: Sys.WebForms.PageRequestManagerServerErrorException: Invalid JSON primitive: {"Top":346,"Left":969,"DockZoneID":"","Collapsed":false,"Pinned":false,"Resizable":true,"Closed":false,"Width":"701px","Height":"904px","ExpandedHeight":0,"Index":-1}.
Line: 6
Char: 84093
Code: 0
URI: http://xm-wvl-02:4201/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=AppContent_ctlAdminTemplatesFreeStyleEdit_RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3a1f68db6e-ab92-4c56-8744-13e09bf43565%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%2c+Version%3d2011.3.1305.40%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen-US%3a8cba3cb6-b29d-4c9f-be22-7b43626a420a%3a16e4e7cd%3aed16cbdc%3af7645509%3a24ee1bba%3af46195d3%3a854aa0a7%3a874f8ea2%3a5a6d9d23%3a7c926187%3a8674cba1%3ab7778d6c%3ac08e9f8a%3aa51ee93e%3a59462f1%3a5f39f986%3a1e771326%3aaa288e2d

So, my questions are:

1. Why do I not get that error in my development machine?
2. What factors should I take into consideration to avoid an INVALID JSON error?
3. Is there a better way of doing what I'm trying to achieve?

Thank you.
Virgil Rodriguez
Top achievements
Rank 1
 answered on 12 Jun 2012
1 answer
704 views
I have a radgrid with all rows in edit mode.
A update button is outside the grid.
<telerik:RadGrid ID="radgridFeeCalc" runat="server" ShowStatusBar="true"
                                    AutoGenerateColumns="False" PageSize="5" AllowPaging="True" AllowSorting="True"
                                    AllowMultiRowSelection="False" AllowAutomaticUpdates="false"
                                    GridLines="None" AllowAutomaticDeletes="false" AllowAutomaticInserts="false"
                                    OnItemDataBound="radgridFeeCalc_ItemDataBound"
                                    >
                                    <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
                                    <MasterTableView DataKeyNames="SEQ_NUM, DST_ID"
                                    AllowMultiColumnSorting="True" ShowFooter="True"
                                    CommandItemDisplay="Top" Name="Address" AllowFilteringByColumn="False" TableLayout="Auto" >
                                        <CommandItemSettings ShowAddNewRecordButton="false" ShowRefreshButton="false" />
                                        <Columns>                                           
                                             
                                            <telerik:GridBoundColumn SortExpression="SEQ_NUM" HeaderText="Sequence" HeaderButtonType="TextButton"
                                                DataField="SEQ_NUM" UniqueName="sEQ_NUM" ReadOnly="true">
                                            </telerik:GridBoundColumn>
                                             
                                            <telerik:GridBoundColumn SortExpression="DESCR" HeaderText="Description" HeaderButtonType="TextButton"
                                                DataField="DESCR" UniqueName="dESCR" ReadOnly="true">
                                            </telerik:GridBoundColumn>
 
                                            <telerik:GridTemplateColumn HeaderText="Calc Amount" DataField="VAL" UniqueName="vAL" >
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="VAL" runat="server" Text='<%# Bind("VAL") %>'></asp:TextBox>
                                                </EditItemTemplate>
                                                <ItemTemplate >
                                                    <asp:TextBox ID="view_VAL" runat="server" Text='<%# Bind("VAL") %>'></asp:TextBox>
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
 
                                            <telerik:GridBoundColumn SortExpression="DST_ID" HeaderText="Distribution Id" HeaderButtonType="TextButton"
                                                DataField="DST_ID" UniqueName="dST_ID" ReadOnly="true">
                                            </telerik:GridBoundColumn>
                                        </Columns>
                                    </MasterTableView>
                                </telerik:RadGrid>
 
                                <telerik:RadButton ID="btnUpdate" runat="server" Text="Update" onclick="btnUpdate_Click"></telerik:RadButton>

How do I get all values from all rows from the grid in an external button "btnUpdate".
I have the following code and can get the datakeyvalues but cannot get the textbox value as the "VAL" textbox is not found.
protected void btnUpdate_Click(object sender, EventArgs e)
        {
            foreach (GridEditFormItem editedItem in radgridFeeCalc.MasterTableView.GetItems(GridItemType.EditFormItem))
            {
                string keyId1 = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["SEQ_NUM"].ToString();
                string keyId2 = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["DST_ID"].ToString();
 
                TextBox combo = ((GridEditFormItem)editedItem).EditFormCell.FindControl("VAL") as TextBox;
                string str1 = combo.Text;
            }
        }

Jayesh Goyani
Top achievements
Rank 2
 answered on 12 Jun 2012
5 answers
186 views
Background:

I have implemented RadScheduler (Q3 ASP.NET AJAX) into a custom MOSS web part. The scheduler is bound to a SharePoint Datasource on the page. The ds is attached to a standard SP task list. I have bound the scheduler start time field to the start date and the scheduler end time field to the due date.

Problem:

I am getting the following error: System.Exception: Appointment is invalid: Start time must be before the End time. at Telerik.Web.UI.Appointment.Validate()

In looking through my task list data, I see that some tasks are scheduled to start and end on the same day. I also see that I have tasks that do not have either a start date or a due date.

I assume my error is being generated from these inconsistencies.

Proposed Resolution:

I think I would need to verify each appointment, but I am unsure as to the best way to handle the exceptions. I am thinking the AppointmentDataBound event could be used to verify each appointment. I could check to make sure all fields exist and make sure the due date is after the start date. Would using this event work? 

Question:

Can the scheduler handle using dates only without a time field? I would like to have all appointments register as full day appointments. If the start date was 5/1 and the due date was 5/2, can the sceduler evaluate this? Also, if the start date and due date were the same, can the scheduler evaluate this? Or do I need to add custom handling in the AppointmentDataBound event for these scenarios?

Thanks.
Peter
Telerik team
 answered on 12 Jun 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?