Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
214 views
Hello,
I'm trying to databind RadGrid control using method provided on this page:

http://www.telerik.com/help/aspnet-ajax/mvc-radgrid-databinding.html

<
   RadGrid1.DataSource = ViewData["Customers"]; 
   RadGrid1.DataBind(); 
%> 
<telerik:RadGrid runat="server" ID="RadGrid1" AutoGenerateColumns="false"
.... 
but when I try to run it I'm getting this error:
Script controls may not be registered after PreRender. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
 
Exception Details: System.InvalidOperationException: Script controls may not be registered after PreRender. 
on the line with .....DataBind();

GrZeCh
Top achievements
Rank 2
 answered on 05 Jun 2009
2 answers
128 views

  I would  like to set the TimeView's StartTime and EndTime once the control has it's value.  The RadDateTimePicker exists within the EditTemplate of a RadGrid.  I tried handling the ItemDataBoundEvent of the RadGrid, finding the RadDateTimePicker and then setting it's TimeView values.  This does not seem to work.  I'm guessing that it's too late in the process.  I need to be able to access the server side (run a query) to know what values to set based on the date selected in the RadDateTimePicker.   Ideas?
Alex Occhipinti
Top achievements
Rank 1
 answered on 05 Jun 2009
2 answers
207 views
I found the articles posted on how to set scroll position client-side for a grid, but it doesn't work for my purpose. I have a master/child grid where I am expanding the selected child, then selecting the row with the data from code. I've implemented a search form on a tab that switches to the main master/child tab with the data, expands the correct child entry, selects it, then fires two more grids that are related.

All of my code works except that I can't move the child grid positions. This is annoying since I'm using it for a medical provider directory. A single expansion can span about 4 screens. If I could pull the scroll into position it would really help the interface and user experience.

A text example of what I'm discussing:

MASTER GRID
  CHILD-A
  CHILD-B
  CHILD-C
  ETC.

Figure the child records go to ZZZZ. I have the key to my desired row, how do I move the scroll bar to this record?

Thanks!

do
Top achievements
Rank 1
 answered on 05 Jun 2009
6 answers
480 views
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ucViewEditSearchEntry.ascx.cs" 
    Inherits="uc_View_Edit_Search_Entry" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<div> 
    <br /> 
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
    &nbsp;  
    <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> 
    <telerik:RadGrid ID="rgViewEditSearchEntry" runat="server" AllowFilteringByColumn="True" 
        AllowSorting="True" GroupingSettings-CaseSensitive="false" PageSize="20" GridLines="None" 
        AutoGenerateColumns="False" OnPageIndexChanged="rgViewEditSearchEntry_PageIndexChanged" 
        AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowPaging="True" 
        ShowStatusBar="True" OnItemUpdated="rgViewEditSearchEntry_ItemUpdated" OnItemDeleted="rgViewEditSearchEntry_ItemDeleted" 
        OnItemInserted="rgViewEditSearchEntry_ItemInserted" OnPreRender="rgViewEditSearchEntry_PreRender" 
        DataSourceID="SessionDataSource1">  
        <HeaderContextMenu EnableTheming="True">  
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
        </HeaderContextMenu> 
        <PagerStyle Mode="NextPrevAndNumeric" /> 
        <MasterTableView DataKeyNames="Premise_Phone" ShowFooter="False" CommandItemSettings-AddNewRecordText="Add New Contact" 
            CommandItemDisplay="TopAndBottom">  
            <CommandItemSettings AddNewRecordText="Add New Blocked Account"></CommandItemSettings> 
            <RowIndicatorColumn> 
                <HeaderStyle Width="20px"></HeaderStyle> 
            </RowIndicatorColumn> 
            <ExpandCollapseColumn> 
                <HeaderStyle Width="20px"></HeaderStyle> 
            </ExpandCollapseColumn> 
            <Columns> 
                <telerik:GridEditCommandColumn UpdateText="Update" UniqueName="EditCommandColumn" 
                    CancelText="Cancel" EditText="Edit">  
                    <HeaderStyle Width="85px"></HeaderStyle> 
                </telerik:GridEditCommandColumn> 
                <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete" /> 
                <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" HeaderText="Id" ReadOnly="True" 
                    SortExpression="Id" UniqueName="Id" FilterControlWidth="20px">  
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="DNIS" HeaderText="DNIS" SortExpression="DNIS" 
                    UniqueName="DNIS" FilterControlWidth="30px">  
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="Prefix" HeaderText="Prefix" SortExpression="Prefix" 
                    UniqueName="Prefix" FilterControlWidth="30px">  
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="Panel_Code" HeaderText="Panel_Code" SortExpression="Panel_Code" 
                    UniqueName="Panel_Code" FilterControlWidth="30px">  
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="Premise_Phone" HeaderText="Premise_Phone" SortExpression="Premise_Phone" 
                    UniqueName="Premise_Phone">  
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="Toll_Free_Number" HeaderText="Toll_Free_Number" 
                    SortExpression="Toll_Free_Number" UniqueName="Toll_Free_Number">  
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="Date_Blocked" DataType="System.DateTime" HeaderText="Date_Blocked" 
                    SortExpression="Date_Blocked" UniqueName="Date_Blocked">  
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="CS_Number" HeaderText="CS_Number" SortExpression="CS_Number" 
                    UniqueName="CS_Number">  
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="Comments" HeaderText="Comments" SortExpression="Comments" 
                    UniqueName="Comments">  
                </telerik:GridBoundColumn> 
            </Columns> 
            <EditFormSettings ColumnNumber="3" CaptionFormatString="Edit details for Blocked Acct with ID {0}" 
                CaptionDataField="Id">  
                <FormTableItemStyle Wrap="False"></FormTableItemStyle> 
                <FormCaptionStyle></FormCaptionStyle>  
                <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" Width="100%" /> 
                <FormTableStyle GridLines="Horizontal" CellSpacing="0" CellPadding="2" Height="110px" 
                    Width="100%" /> 
                <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> 
                <FormStyle Width="100%" BackColor="#eef2ea"></FormStyle> 
                <EditColumn UpdateText="Update record" UniqueName="EditCommandColumn1" CancelText="Cancel edit">  
                </EditColumn> 
                <FormTableButtonRowStyle HorizontalAlign="Left"></FormTableButtonRowStyle> 
            </EditFormSettings> 
        </MasterTableView> 
        <GroupingSettings CaseSensitive="False"></GroupingSettings> 
        <FilterMenu EnableTheming="True">  
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
        </FilterMenu> 
    </telerik:RadGrid> 
    <asp:SqlDataSource ID="SessionDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:RxLogConnectionString %>" 
        ProviderName="System.Data.SqlClient" OldValuesParameterFormatString="original_{0}" 
        SelectCommand="SELECT Id, DNIS, Prefix, Panel_Code, Premise_Phone, Toll_Free_Number, Date_Blocked, CS_Number, Comments FROM [BlokedAcc]" 
        DeleteCommand="DELETE FROM [BlokedAcc] WHERE [Id] = Id"   
        InsertCommand="INSERT INTO [BlokedAcc] ([DNIS], [Prefix], [Panel_Code], [Premise_Phone], [Toll_Free_Number], [Date_Blocked], [CS_Number], [Comments]) VALUES (DNIS, Prefix, Panel_Code, Premise_Phone, Toll_Free_Number, Date_Blocked, CS_Number, Comments)" 
        UpdateCommand="UPDATE [BlokedAcc] SET [DNIS] = DNIS, [Prefix] = Prefix, [Panel_Code] = Panel_Code, [Premise_Phone] = Premise_Phone, [Toll_Free_Number] = Toll_Free_Number, [Date_Blocked] = Date_Blocked, [CS_Number] = CS_Number, [Comments] = Comments WHERE [Id] = Id" 
        ConflictDetection="CompareAllValues">  
        <DeleteParameters> 
            <asp:Parameter Name="Id" Type="String" /> 
            <asp:Parameter Name="original_Id" Type="Int64"></asp:Parameter> 
            <asp:Parameter Name="original_DNIS" Type="String"></asp:Parameter> 
            <asp:Parameter Name="original_Prefix" Type="String"></asp:Parameter> 
            <asp:Parameter Name="original_Panel_Code" Type="String"></asp:Parameter> 
            <asp:Parameter Name="original_Premise_Phone" Type="String"></asp:Parameter> 
            <asp:Parameter Name="original_Toll_Free_Number" Type="String"></asp:Parameter> 
            <asp:Parameter Name="original_Date_Blocked" Type="DateTime"></asp:Parameter> 
            <asp:Parameter Name="original_CS_Number" Type="String"></asp:Parameter> 
            <asp:Parameter Name="original_Comments" Type="String"></asp:Parameter> 
        </DeleteParameters> 
        <UpdateParameters> 
            <asp:Parameter Name="Id" Type="Int64" /> 
            <asp:Parameter Name="DNIS" Type="String" /> 
            <asp:Parameter Name="Prefix" Type="String" /> 
            <asp:Parameter Name="Panel_Code" Type="String" /> 
            <asp:Parameter Name="Premise_Phone" Type="String" /> 
            <asp:Parameter Name="Toll_Free_Number" Type="String" /> 
            <asp:Parameter Name="Date_Blocked" Type="DateTime" /> 
            <asp:Parameter Name="CS_Number" Type="String" /> 
            <asp:Parameter Name="Comments" Type="String" /> 
            <asp:Parameter Name="original_Id" Type="Int64" /> 
            <asp:Parameter Name="original_DNIS" Type="String" /> 
            <asp:Parameter Name="original_Prefix" Type="String" /> 
            <asp:Parameter Name="original_Panel_Code" Type="String" /> 
            <asp:Parameter Name="original_Premise_Phone" Type="String" /> 
            <asp:Parameter Name="original_Toll_Free_Number" Type="String" /> 
            <asp:Parameter Name="original_Date_Blocked" Type="DateTime" /> 
            <asp:Parameter Name="original_CS_Number" Type="String" /> 
            <asp:Parameter Name="original_Comments" Type="String" /> 
        </UpdateParameters> 
        <InsertParameters> 
            <asp:Parameter Name="@DNIS" Type="String" /> 
            <asp:Parameter Name="@Prefix" Type="String" /> 
            <asp:Parameter Name="@Panel_Code" Type="String" /> 
            <asp:Parameter Name="@Premise_Phone" Type="String" /> 
            <asp:Parameter Name="@Toll_Free_Number" Type="String" /> 
            <asp:Parameter Name="@Date_Blocked" Type="DateTime" /> 
            <asp:Parameter Name="@CS_Number" Type="String" /> 
            <asp:Parameter Name="@Comments" Type="String" /> 
        </InsertParameters> 
    </asp:SqlDataSource> 
</div> 
 
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;  
using System.Collections;  
using System.Configuration;  
using System.Data;  
using System.Web.Security;  
using System.Text;  
using System.Data.SqlClient;  
using System.Web.UI.WebControls.WebParts;  
using System.Web.UI.HtmlControls;  
using System.Drawing;  
 
 
public partial class uc_View_Edit_Search_Entry : System.Web.UI.UserControl  
{  
    protected override void OnLoad(EventArgs e)  
    {  
        rgViewEditSearchEntry.DataBind();  
    }  
 
    protected void rgViewEditSearchEntry_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e)  
    {  
        rgViewEditSearchEntry.DataBind();  
    }  
 
    protected void rgViewEditSearchEntry_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e)  
    {  
        if (e.Exception != null)  
        {  
            e.KeepInEditMode = true;  
            e.ExceptionHandled = true;  
            DisplayMessage(true"Id " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"] + " cannot be updated. Reason: " + e.Exception.Message);  
        }  
        else 
        {  
            DisplayMessage(false"Id " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"] + " updated");  
        }  
    }  
 
    protected void rgViewEditSearchEntry_ItemInserted(object source, GridInsertedEventArgs e)  
    {  
        if (e.Exception != null)  
        {  
            e.ExceptionHandled = true;  
            e.KeepInInsertMode = true;  
            DisplayMessage(true"Id cannot be inserted. Reason: " + e.Exception.Message);  
        }  
        else 
        {  
            DisplayMessage(false"Id inserted");  
        }  
    }  
 
    protected void rgViewEditSearchEntry_ItemDeleted(object source, GridDeletedEventArgs e)  
    {  
        if (e.Exception != null)  
        {  
            e.ExceptionHandled = true;  
            DisplayMessage(true"Id " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"] + " cannot be deleted. Reason: " + e.Exception.Message);  
        }  
        else 
        {  
            DisplayMessage(false"Id " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"] + " deleted");  
        }  
    }  
 
    private void DisplayMessage(bool isError, string text)  
    {  
        this.Label1.Font.Bold = true;  
        this.Label1.Visible = true;  
        if (isError)  
        {  
            this.Label1.ForeColor = Color.Red;  
        }  
        else 
        {  
            this.Label1.ForeColor = Color.Green;  
        }  
 
        this.Label1.Text = text;  
    }  
 

????
Jon-Jon Kershaw
Top achievements
Rank 2
 answered on 05 Jun 2009
2 answers
113 views
Hi,
I am trying to get the length of the text that I have entered in the RAD Editor. While the character count box at the bottom of the editor gives the correct count(which uses js: editor.get_html), the function in which I use "RadEditor1.Content" to return the count, seems to be adding the enter characters in the text and hence there seems to be a mismatch between the actual character count shown at the bottom and the one the code is checking against -for validation. Am I missing something here. Your input is highly appreciated. Thanks.
Anandi
Anandi
Top achievements
Rank 1
 answered on 05 Jun 2009
0 answers
97 views
Hi
          I used the rad tab control.. i have used four tab like persoal info, contact detail , legal info , notes... This Table are Inserted in Single Time single Save button stored in Database. in this tab i have used the Enterprise validations Control. Here the validation message showing in active tab. another tab is not showing that why the customer cannot identify the validation message. how can i solve this problem.

          I think inside the tab i can used the multipage. that why the message is showing only active page... please let me know how can i solved this problem


Regards
G. Manikandan


 
mani
Top achievements
Rank 1
 asked on 05 Jun 2009
2 answers
315 views
Hi,
I'm trying to export a grouped grid to excel. Only one issue left...

In RadGrid1_ItemDataBound I change the value of a column "totalseconds" from a number (92) to a string (1:32). Basically I'm converting seconds to a minute string. When I export to Excel, the column "totalseconds" spits out a bunch of zeros, instead of the updated value. The zeroes are not even the correct "original" values.

I think the question is... how do I maintain the updated value, from ItemDataBound, when exporting to Excel? I tried changing the value in ItemCreated and PreRender, but that didn't seem to work either. I have also tried everything in "Exporting Tips and Tricks" to no avail.

Here's the relevant code:

 

<telerik:radgrid AllowSorting="true" AutoGenerateColumns="false" AllowFilteringByColumn="False" 
            AllowPaging="true" PageSize="20" id="RadGrid1" Skin="Gray" runat="server" OnExcelExportCellFormatting="RadGrid1_ExcelExportCellFormatting">  
            <MasterTableView> 
               <GroupByExpressions> 
                 <telerik:GridGroupByExpression> 
                   <SelectFields> 
                       <telerik:GridGroupByField FieldAlias="Activity" FieldName="daterounded" FormatString="{0:D}" HeaderValueSeparator=" from date: "></telerik:GridGroupByField> 
                   </SelectFields> 
                   <GroupByFields> 
                       <telerik:GridGroupByField FieldName="daterounded" SortOrder="Descending"></telerik:GridGroupByField> 
                   </GroupByFields> 
                 </telerik:GridGroupByExpression> 
                </GroupByExpressions> 
                <SortExpressions> 
                    <telerik:GridSortExpression FieldName="dateadded" SortOrder="Descending" /> 
                </SortExpressions> 
                <Columns> 
                    <telerik:GridBoundColumn DataField="dateadded" UniqueName="dateadded" HeaderText="Activity Date (EST)" /> 
                    <telerik:GridBoundColumn DataField="title" UniqueName="title" HeaderText="Lesson Title" /> 
                    <telerik:GridBoundColumn DataField="status" UniqueName="status" HeaderText="Lesson Status" /> 
                    <telerik:GridBoundColumn DataField="totalseconds" UniqueName="totalseconds" HeaderText="Total Time" /> 
                </Columns> 
            </MasterTableView> 
</telerik:radgrid> 

 

Private Sub RadGrid1_NeedDataSource(ByVal [source] As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs)_ Handles RadGrid1.NeedDataSource  
        ' Populate RadGrid from DB  
End Sub 
 
Private Sub RadGrid1_ItemDataBound(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound  
        If TypeOf e.Item Is GridDataItem Then 
            Dim item As GridDataItem = e.Item  
            Dim totalseconds As Integer = CInt(item("totalseconds").Text)  
            Dim totaltime As String = formatTime(totalseconds) 'formatTime returns a string  
            item("totalseconds").Text = totaltime  
        End If 
End Sub 
 
Protected Sub btnExport_Click(ByVal sender As ObjectByVal e As System.Web.UI.ImageClickEventArgs) Handles btnExport.Click  
        RadGrid1.ExportSettings.ExportOnlyData = True 
        RadGrid1.ExportSettings.IgnorePaging = True 
        RadGrid1.ExportSettings.OpenInNewWindow = True 
        RadGrid1.MasterTableView.ExportToExcel()  
End Sub 
 

Any ideas?
Thanks,
Joe
Joe
Top achievements
Rank 2
 answered on 05 Jun 2009
1 answer
63 views
Telerik - you rock.  I've been digging Telerik for about 5 years now and must say "thank you" for the quality controls!

When using the RadScheduler, I've noticed a small bug.  If I set MonthView-AdaptiveRowHeight="True", and have a row on the calendar with now events, I am unable to drag & drop events from other rows to that row.  I can drag them to rows that contain events, but cannot drag them to rows without events.

Make sense?

For now, I'm just not using AdaptiveRowHeight, but wanted to report this to see if anyone else can replicate the behavior.

Take care,

MJ
Peter
Telerik team
 answered on 05 Jun 2009
2 answers
186 views
Hi

If Radgrid in edit mode i would like to know how can i get the new value intered by user in cell ?

thanks

Fadi
Curtis
Top achievements
Rank 1
 answered on 05 Jun 2009
0 answers
108 views
Hi,

I have a <ve:Map....> control on my page and it works fine. I am using its, onserverclick, onserverfind, and onclientclick handlers. Here is the code for the control.

ve:Map ID="vemapDealerLocator" runat="server" Height="491px" Width="491px" ZoomLevel="2"
        OnServerClick="vemapDealerLocator_ServerClick" OnServerFind="vemapDealerLocator_ServerFind"
        OnClientClick="ClientClick" Center-Longitude="0" Center-Latitude="0" DashboardSize="Small" />



Now when I click on the map the onserverclick goes back to the server and calls the appropriate function in both the IE and Google Chrome browsers, but  for some reason when I try it in Firefox the following exception is thrown:
[Exception... "'Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: 281.79998779296875 is not a valid value for Int32.' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001c (NS_ERROR_XPC_JS_THREW_JS_OBJECT)" location: "JS frame :: chrome://firebug/content/spy.js :: onHTTPSpyReadyStateChange :: line 497" data: no]
mapcontrol.ashx?v=6.1()()mapcontr...shx?v=6.1 (line 126)
;this.CreditsFor=function(a,i,j,h){var e...efined")closeDependency("mapcontrol.js")

Can you please tell me the reason for this error?

Thanks,
Monzer
Monzer
Top achievements
Rank 1
 asked on 05 Jun 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?