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

Grid_PageSizeChanged problem

2 Answers 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
liu qingshui
Top achievements
Rank 1
liu qingshui asked on 18 Mar 2010, 06:20 AM
when the Grid_PageSizeChanged Event fire,there is error:
It is impossible to change from  “Telerik.Web.UI.RadGrid”  to  “Telerik.Web.UI.GridTableView”.
Please give me a idea!
    protected void Grid_PageSizeChanged(object source, GridPageSizeChangedEventArgs e) 
    { 
        BindGridSpecial(); 
    } 
 
 private void BindGridSpecial() 
    { 
        Template[] listAll = Template.FindAll(); 
        List<TemplateItem> listTemplateItemAll = new List<TemplateItem>(); 
        foreach (Template tm in listAll) 
        { 
            if (tm.IsSpecial == true && tm.TemplateID != 0) 
            { 
                TemplateVersion version = TemplateVersion.FindDeployVersion(tm.TemplateID); 
                TemplateCategory[] category0 = TemplateCategory.FindAll(); 
                List<TemplateCategory> categoryList = new List<TemplateCategory>(); 
                foreach (TemplateCategory tc in category0) 
                { 
                    if (tc.TemplateVersion.ToString() == version.ToString()) 
                    { 
                        TemplateCategory categroy = TemplateCategory.Find(tc.TemplateCategoryID); 
                        TemplateItem[] itemList = TemplateItem.FindAll(version.TemplateVerID, categroy.TemplateCategoryID); 
                        listTemplateItemAll.AddRange(itemList); 
 
                    } 
                } 
 
            } 
        } 
        Grid.DataSource = listTemplateItemAll; 
        Grid.DataBind(); 
 
    } 

<telerik:RadGrid ID="Grid" runat="server" Width="100%" AllowPaging="True" AllowSorting="True" 
            EnableViewState="true" AutoGenerateColumns="False" GridLines="None" OnItemDataBound="Grid_ItemDataBound" 
            OnPageIndexChanged="Grid_PageIndexChanged" OnPageSizeChanged="Grid_PageSizeChanged" 
            OnSortCommand="Grid_SortCommand"
            <MasterTableView DataKeyNames="TemplateItemID"
                <RowIndicatorColumn> 
                    <HeaderStyle Width="20px" /> 
                </RowIndicatorColumn> 
                <ExpandCollapseColumn> 
                    <HeaderStyle Width="20px" /> 
                </ExpandCollapseColumn> 
                <Columns> 
                    <telerik:GridClientSelectColumn UniqueName="column2"
                    </telerik:GridClientSelectColumn> 
                    <telerik:GridBoundColumn DataField="Name" HeaderText="项" SortExpression="Name" UniqueName="Name"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="Description" HeaderText="说明" SortExpression="Description" 
                        UniqueName="Description"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="Item Type" HeaderText="类型" SortExpression="ItemType" 
                        UniqueName="Item Type"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="StartHour" HeaderText="开始时间" SortExpression="StartHour" 
                        UniqueName="StartHour"
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="EndHour" HeaderText="截止时间" SortExpression="EndHour" 
                        UniqueName="EndHour"
                    </telerik:GridBoundColumn> 
                    <telerik:GridCheckBoxColumn DataField="IsAudit" HeaderText="是否审核" SortExpression="IsAudit" 
                        UniqueName="IsAudit"
                    </telerik:GridCheckBoxColumn> 
                </Columns> 
            </MasterTableView> 
        </telerik:RadGrid> 

2 Answers, 1 is accepted

Sort by
0
Accepted
Tsvetoslav
Telerik team
answered on 19 Mar 2010, 07:57 AM
Hello liu,

You should be using Advanced databinding as opposed to Simple data binding.

Greetings,
Tsvetoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
liu qingshui
Top achievements
Rank 1
answered on 19 Mar 2010, 11:33 AM
Thank your kind help.
Now I use the advanced databinding, but the problem is still there!
The new code is below:
    protected void rgridview_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) 
    { 
        USRoleScheduleLog[] roleScheduleLog = USRoleScheduleLog.FindAll(); 
        rgridview.DataSource = roleScheduleLog; 
    } 
 





Tags
Grid
Asked by
liu qingshui
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
liu qingshui
Top achievements
Rank 1
Share this question
or