Hi,
I have a grid with set of GridBoundColumn, GridNumericColumn, GridDateTimeColumn etc., and Column reorder option enabled. i made reordering through client side by using property called ReorderColumnsOnClient="true". While reordering any column, the issue i faced is after reordered a GridNumeric column where GridBoundColumn is actually placed and vice versa., then filtering a reodered column, it throws a Type cast error.
"Message: Sys.WebForms.PageRequestManagerServerErrorException: Unable to cast object of type 'System.Web.UI.WebControls.TextBox' to type 'Telerik.Web.UI.RadNumericTextBox'. "
if i try to reorder a DatePickerColumn with numeric column it throws an exception as like follows :
"Message: Sys.WebForms.PageRequestManagerServerErrorException: Unable to cast object of type 'Telerik.Web.UI.RadDatePicker' to type 'Telerik.Web.UI.RadNumericTextBox'"
Kindly suggest a solution for this problem.
thanks and regards
Venk@t
I have a grid with set of GridBoundColumn, GridNumericColumn, GridDateTimeColumn etc., and Column reorder option enabled. i made reordering through client side by using property called ReorderColumnsOnClient="true". While reordering any column, the issue i faced is after reordered a GridNumeric column where GridBoundColumn is actually placed and vice versa., then filtering a reodered column, it throws a Type cast error.
"Message: Sys.WebForms.PageRequestManagerServerErrorException: Unable to cast object of type 'System.Web.UI.WebControls.TextBox' to type 'Telerik.Web.UI.RadNumericTextBox'. "
if i try to reorder a DatePickerColumn with numeric column it throws an exception as like follows :
"Message: Sys.WebForms.PageRequestManagerServerErrorException: Unable to cast object of type 'Telerik.Web.UI.RadDatePicker' to type 'Telerik.Web.UI.RadNumericTextBox'"
Kindly suggest a solution for this problem.
thanks and regards
Venk@t
6 Answers, 1 is accepted
0
Jayesh Goyani
Top achievements
Rank 2
answered on 17 Mar 2012, 06:27 AM
Hello Venkat,
can you please provide C# code?
Thanks,
Jayesh Goyani
can you please provide C# code?
Thanks,
Jayesh Goyani
0
Venkat
Top achievements
Rank 1
answered on 17 Mar 2012, 06:59 PM
Hello Jayesh Goyani,
Thanks for your reply. my sample code were followed by:
ASPX Code:
c# code
Thanks and Regards,
Venk@t
Thanks for your reply. my sample code were followed by:
ASPX Code:
<form id="form1" runat="server"><div><telerik:RadDatePicker ID="datePicker" runat="server" DateInput-ReadOnly="true"></telerik:RadDatePicker><telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_OnNeedDataSource" AutoGenerateColumns="false" AllowFilteringByColumn="true" OnItemCommand="RadGrid1_OnItemCommand" OnItemCreated="RadGrid_OnItemCreated"><MasterTableView><Columns><telerik:GridBoundColumn UniqueName="NAME" DataField="NAME" HeaderText="NAME"></telerik:GridBoundColumn><telerik:GridBoundColumn UniqueName="LASTNAME" DataField="LASTNAME" HeaderText="LASTNAME"></telerik:GridBoundColumn><telerik:GridNumericColumn UniqueName="ID" DataField="ID" HeaderText="ID"></telerik:GridNumericColumn><telerik:GridDateTimeColumn UniqueName="DATE" DataField="DATE" HeaderText="DATE"></telerik:GridDateTimeColumn></Columns></MasterTableView><ClientSettings AllowColumnsReorder="true" ReorderColumnsOnClient="false"></ClientSettings></telerik:RadGrid> </div><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager></form>c# code
public partial class _Default : System.Web.UI.Page { List<GridData> GridSourceList = null; protected void Page_Load(object sender, EventArgs e) { GridSourceList = new List<GridData>(); GridSourceList.Add(new GridData("Abdul", "Abdul", 001, new DateTime(2012, 1, 1))); GridSourceList.Add(new GridData("Baskar", "Baskar", 002, new DateTime(2012, 1, 2))); GridSourceList.Add(new GridData("Chandran", "Chandran", 003, new DateTime(2012, 1, 3))); } protected void RadGrid1_OnNeedDataSource(object sender, EventArgs e) { string strFilterExpression = RadGrid1.MasterTableView.FilterExpression; RadGrid1.DataSource = GridSourceList; } protected void RadGrid1_OnItemCommand(object sender, GridCommandEventArgs e) { } protected void RadGrid_OnItemCreated(object sender, GridItemEventArgs e) { if (e.Item is GridFilteringItem) { GridFilteringItem item = (GridFilteringItem)e.Item; RadDatePicker txt = (RadDatePicker)item["DATE"].Controls[0]; txt.DateInput.ReadOnly = true; } }}public class GridData{ public GridData(string strFirstName,string strLastname, int intID, DateTime dateTime) { _firstname = strFirstName; _lastname = strLastname; _id = intID; _date = dateTime; } private string _firstname; private string _lastname; private int _id; private DateTime _date; public DateTime DATE { get { return _date; } set { _date = value; } } public string NAME { get{return _firstname;} set{_firstname = value;} } public int ID { get { return _id; } set { _id = value; } } public string LASTNAME { get { return _lastname; } set { _lastname = value; } }}Thanks and Regards,
Venk@t
0
Jayesh Goyani
Top achievements
Rank 2
answered on 17 Mar 2012, 07:25 PM
Hello,
I tried with your code and its work fine from my site.
my telerik version : 2011.2.915.40
Thanks,
Jayesh Goyani
I tried with your code and its work fine from my site.
my telerik version : 2011.2.915.40
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 TelerikTest.Web{ public partial class aaaa : System.Web.UI.Page { List<GridData> GridSourceList = null; protected void Page_Load(object sender, EventArgs e) { GridSourceList = new List<GridData>(); GridSourceList.Add(new GridData("Abdul", "Abdul", 001, new DateTime(2012, 1, 1))); GridSourceList.Add(new GridData("Baskar", "Baskar", 002, new DateTime(2012, 1, 2))); GridSourceList.Add(new GridData("Chandran", "Chandran", 003, new DateTime(2012, 1, 3))); } protected void RadGrid1_OnNeedDataSource(object sender, EventArgs e) { string strFilterExpression = RadGrid1.MasterTableView.FilterExpression; RadGrid1.DataSource = GridSourceList; } protected void RadGrid1_OnItemCommand(object sender, GridCommandEventArgs e) { } protected void RadGrid_OnItemCreated(object sender, GridItemEventArgs e) { if (e.Item is GridFilteringItem) { GridFilteringItem item = (GridFilteringItem)e.Item; RadDatePicker txt = (RadDatePicker)item["DATE"].Controls[0]; txt.DateInput.ReadOnly = true; } } //protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) //{ // dynamic data = new[] { // new { ID = 1, Name ="name1"}, // new { ID = 2, Name = "name2"}, // new { ID = 3, Name = "name3"}, // new { ID = 4, Name = "Name4"}, // new { ID = 1, Name ="name5"}}; // RadGrid1.DataSource = data; //} } public class GridData { public GridData(string strFirstName, string strLastname, int intID, DateTime dateTime) { _firstname = strFirstName; _lastname = strLastname; _id = intID; _date = dateTime; } private string _firstname; private string _lastname; private int _id; private DateTime _date; public DateTime DATE { get { return _date; } set { _date = value; } } public string NAME { get { return _firstname; } set { _firstname = value; } } public int ID { get { return _id; } set { _id = value; } } public string LASTNAME { get { return _lastname; } set { _lastname = value; } } }}<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="aaaa.aspx.cs" Inherits="TelerikTest.Web.aaaa" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <div> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> </telerik:RadScriptManager> <telerik:RadDatePicker ID="datePicker" runat="server" DateInput-ReadOnly="true"> </telerik:RadDatePicker> <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_OnNeedDataSource" AutoGenerateColumns="false" AllowFilteringByColumn="true" OnItemCommand="RadGrid1_OnItemCommand" OnItemCreated="RadGrid_OnItemCreated"> <MasterTableView> <Columns> <telerik:GridBoundColumn UniqueName="NAME" DataField="NAME" HeaderText="NAME"> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="LASTNAME" DataField="LASTNAME" HeaderText="LASTNAME"> </telerik:GridBoundColumn> <telerik:GridNumericColumn UniqueName="ID" DataField="ID" HeaderText="ID"> </telerik:GridNumericColumn> <telerik:GridDateTimeColumn UniqueName="DATE" DataField="DATE" HeaderText="DATE"> </telerik:GridDateTimeColumn> </Columns> </MasterTableView> <ClientSettings AllowColumnsReorder="true" ReorderColumnsOnClient="false"> </ClientSettings> </telerik:RadGrid> </div> </form></body></html>Thanks,
Jayesh Goyani
0
Venkat
Top achievements
Rank 1
answered on 18 Mar 2012, 06:47 AM
Hello Jayesh Goyani,
Thanks for your reply, but my scenario is that i want to reorder the column through client side alone. Is that possible to do by getting without typecast error that i mentioned above ?
thanks and regards
Venk@t
Thanks for your reply, but my scenario is that i want to reorder the column through client side alone. Is that possible to do by getting without typecast error that i mentioned above ?
thanks and regards
Venk@t
0
Jayesh Goyani
Top achievements
Rank 2
answered on 18 Mar 2012, 02:35 PM
Hello Venkat,
Can you please provide your project using support ticket?
So we can able to find the issue in your code.
Thanks,
Jayesh Goyani
Can you please provide your project using support ticket?
So we can able to find the issue in your code.
Thanks,
Jayesh Goyani
0
Venkat
Top achievements
Rank 1
answered on 19 Mar 2012, 07:55 AM
Hello Jayesh goyani,
I am unable to provide my code since it is confidential data. anyway thanks for your reply. i have a another doubt with reordering column. As you suggest i try to reorder my column by making
I am unable to provide my code since it is confidential data. anyway thanks for your reply. i have a another doubt with reordering column. As you suggest i try to reorder my column by making
ReorderColumnsOnClient = "false"; during this process grid on-prerender event
is not fired after itemdatabound event while reordering. am i missunderstood Radgrid event life-cycle ?
thanks and regards,
Venk@t