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

[Solved] Paging problem with heirarchy grid

2 Answers 247 Views
Grid
This is a migrated thread and some comments may be shown as answers.
joni
Top achievements
Rank 1
joni asked on 25 Jun 2008, 05:14 PM
Hi,
I'm getting an error when I try to page using  Master/Detail tables. The error I get is :

Sys.WebForms.PageRequestManagerServerErrorException: Syntax error: Missing operand before 'And' operator.

I'm using version 2008.1.610.35 of the grid.  Here is the code that is executed in the NeedDataSource:

this

.RadGrid1.MasterTableView.DataKeyNames = new string[] { "ndc" };

this.RadGrid1.MasterTableView.DataMember = "NDCMaster";

this.RadGrid1.MasterTableView.AllowPaging = true;



NDCMaster

master = new NDCMaster();

DataSet dsMaster = master.GetDataSetforNDCMaster();

this.RadGrid1.MasterTableView.DataSource = dsMaster;

this.RadGrid1.MasterTableView.DataMember = "NDCMaster";

this.RadGrid1.MasterTableView.DataKeyNames = new string[]{"ndc"};

 

GridRelationFields fields = new GridRelationFields();

fields.DetailKeyField =

"ndc";

fields.MasterKeyField =

"ndc";

detailView =

new GridTableView(this.RadGrid1);

this.RadGrid1.MasterTableView.DetailTables.Add(detailView);

this.RadGrid1.MasterTableView.DetailTables[0].ParentTableRelation.Add(fields);

NDCDetail detail = new NDCDetail();

DataSet dsDetail = detail.GetDataSetforNDCDetail();

this.RadGrid1.MasterTableView.DetailTables[0].DataSource = dsDetail;

this.RadGrid1.MasterTableView.DetailTables[0].DataMember = "NDCDetails";

this.RadGrid1.MasterTableView.DetailTables[0].Width = Unit.Percentage(100);

Here is the code in the aspx:

<

telerik:RadGrid ID="RadGrid1" runat="server"

onneeddatasource="RadGrid1_NeedDataSource"

GridLines="None" ShowGroupPanel="True" onpageindexchanged="RadGrid1_PageIndexChanged"

>

<

MasterTableView hierarchyloadmode="ServerBind">

<

RowIndicatorColumn>

<

HeaderStyle Width="20px"></HeaderStyle>

</

RowIndicatorColumn>

<

ExpandCollapseColumn>

<

HeaderStyle Width="20px"></HeaderStyle>

</

ExpandCollapseColumn>

</

MasterTableView>

<ClientSettings AllowDragToGroup="True">

</ClientSettings>

</telerik:RadGrid>

I'm using the auto-generate columns at runtime.  Any help is appreciated - thanks!

Edited to add - I did originally assign the datasource and datamember to the detailView:

detailView.DataSource = dsDetail;

detailView.DataMember =

"NDCDetails";


But then when I try to page I get the error:

IListSource does not contain a datasource named "NDCDetails". Check your DataMember value.

So I assigned them to the Masterview detail table - that's when I get the
Sys.WebForms.PageRequestManagerServerErrorException: Syntax error: Missing operand before 'And' operator.
error. Thanks!

joni

2 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 30 Jun 2008, 11:23 AM
Hello joni,

If you would like to define the parent table relations for your grid (and the entire grid instance programmatically), you need to do that inside the PageInit handler of the page as depicted in the following articles from the online documentation:

http://www.telerik.com/help/aspnet-ajax/grdprogrammaticcreation.html
http://www.telerik.com/help/aspnet-ajax/mostcommonmistakes.html (the first paragraph)
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/Programming/Hierarchy/DefaultCS.aspx

Thus you will ensure that the viewstate of the grid will remain consistent and its built-in features will function as expected. Additionally, I recommend you use the Name property of the MasterTableView/GridTableView since it is applicable for NET 2.x/3.x when using declarative data sources or assigning the grid source programmatically:

http://www.telerik.com/help/aspnet-ajax/grddistinguishgridrowsinhierarchyonitemdatabound.html (see the last paragraph of the topic)

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
joni
Top achievements
Rank 1
answered on 30 Jun 2008, 02:36 PM
Hi Stephen,
I changed the initialization to occur in the OnInit and made a few minor changes in the DetailTableDataBind event handler and it works great now! Thanks for your help!

joni
Tags
Grid
Asked by
joni
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
joni
Top achievements
Rank 1
Share this question
or