This is a migrated thread and some comments may be shown as answers.

frid not showing data

3 Answers 67 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ajay
Top achievements
Rank 1
Ajay asked on 25 Jan 2011, 12:55 PM
Hi
I am using VS 2010 and telerik controls and some how the grids on the page is not displaying the data.
I am using following code.
ASPX
<div style="width: 80%">
                <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1">
                    <div style="float: left; height: 100%; width: 55px; background: #E3EFFF; text-align: center;
                        border-right: 1px solid #6593CF;">
                        <img src="images/tasks.gif" alt="" /></div>
                    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True"
                        GridLines="None" Width="585px">
                        <MasterTableView AllowMultiColumnSorting="true" />
                        <SortingSettings SortedBackColor="Azure" EnableSkinSortStyles="false" />
                        <HeaderStyle Width="100px" />
                    </telerik:RadGrid>
                </telerik:RadAjaxPanel>
            </div>


protected void PRate_Load(object sender, EventArgs e)
        {
            LoadData();
        }
        protected void LoadData()
        {
            var Person = TypeCreator.TypeGenerator(new[]{
                new {ID=1, PackageName="1 Week", Duration="1 Week",   Rate=29, Price=100},
                new {ID=2, PackageName="1 Month(s)", Duration="1 Week",   Rate=29, Price=100},
                new {ID=3, PackageName="3 Month(s)", Duration="1 Week" , Rate=29, Price=100},
                new {ID=4, PackageName="6 Month(s)", Duration="1 Week",  Rate=29, Price=100},
                new {ID=5, PackageName="9 Month(s)", Duration="1 Week",   Rate=29, Price=100},
                new {ID=6, PackageName="12 Month(s)", Duration="1 Week", Rate=29, Price=100}
            });
            //none of the method is working,
 
            var dt = new System.Data.DataTable();
            dt.Columns.Add(new System.Data.DataColumn("ID", typeof(System.Int16)));
            dt.Columns.Add(new System.Data.DataColumn("PackageName", typeof(System.String)));
            dt.Columns.Add(new System.Data.DataColumn("Duration", typeof(System.String)));
            System.Data.DataRow dr;
            for (int i = 0; i < 100; i++)
            {
                dr = dt.NewRow();
                dr[0] = i;
                dr[1] = "Package" + i;
                dr[2] = i * 10;
                dt.Rows.Add(dr);
            }
 
 
            RadGrid1.DataSource = dt;
            RadGrid1.DataBind();
        }
 
 
   static class TypeCreator
    {
        public static List<T> TypeGenerator<T>(this T[] t)
        {
            return new List<T>(t);
        }
    }

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 25 Jan 2011, 01:57 PM
Hello Ajay,

The correct approach when using simple data-binding is to call the DataBind() method on the first page load when !Page.IsPostBack and after handling some event (sort event for example). However, I recommend that you review the following online resources:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/simplebinding/defaultcs.aspx
http://www.telerik.com/help/aspnet-ajax/grdsimpledatabinding.html

Kind regards,
Pavlina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Ajay
Top achievements
Rank 1
answered on 25 Jan 2011, 03:57 PM
hi
thanks for the quick reply.
actually the problem is with the pageload,
the name of pageload function is renamed and the page event is never firing.
0
Pavlina
Telerik team
answered on 26 Jan 2011, 06:20 PM
Hi Ajay,

If you need additional assistance, please do not hesitate to let us know.

Greetings,
Pavlina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Ajay
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Ajay
Top achievements
Rank 1
Share this question
or