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

a strange bug in binding of grid

5 Answers 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
lina fetisova
Top achievements
Rank 1
lina fetisova asked on 08 Sep 2010, 05:27 AM
Good day!
I have got m own class News
I've made a child class NewsForSite

public class NewsForSite : News
    {
        public string SitesTree;
    }


NewsForSite has one more parametr - string SitesTree.

I'm making NewsForSite exemplar on base of News exemplar by coping all the parameters of News to NewsForSite and writing SitesTree string to each NewsForSite.
In debugger (you can see it at attached picture) I can see that all of paramerts of NewsForSite are in base collection and SitesTree parametr is outstanding, and when I try to bind this parametr to grid like other parmetrs, there is an empty space instead of SitesTree stings in grid. Otner columns look well.
I bind all the parametrs this way:

grUsersGroup.DataSource=newsWithSitesList; //( var newsWithSitesList = new List<NewsForSite>();)

<telerik:RadGrid  ID="grUsersGroup" runat="server" >
        <MasterTableView AutoGenerateColumns="False" EditMode="PopUp" DataKeyNames="Id">
             <Columns>
                <telerik:GridBoundColumn DataField="Id" HeaderText="ID"
                    SortExpression="Id" UniqueName="Id" ReadOnly="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="SitesTree" HeaderText="Где опубликована"
                    SortExpression="SitesTree" UniqueName="SitesTree" ReadOnly="true" AllowFiltering="true">
                </telerik:GridBoundColumn>            
             </Columns>            
        </MasterTableView>
    </telerik:RadGrid>

what is the right way of binding of SitesTree to me?

5 Answers, 1 is accepted

Sort by
0
lina fetisova
Top achievements
Rank 1
answered on 09 Sep 2010, 07:15 AM
any ideas? =)
0
Mira
Telerik team
answered on 09 Sep 2010, 04:06 PM
Hello Lina,

Please try using the following code and let me know whether it works:
<telerik:RadGrid  ID="grUsersGroup" runat="server" >
        <MasterTableView AutoGenerateColumns="False" EditMode="PopUp" DataKeyNames="Id">
             <Columns>
                <telerik:GridBoundColumn DataField="Id" HeaderText="ID"
                    SortExpression="Id" UniqueName="Id" ReadOnly="true">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="NewsForSite.SitesTree" HeaderText="Где опубликована"
                    SortExpression="SitesTree" UniqueName="SitesTree" ReadOnly="true" AllowFiltering="true">
                </telerik:GridBoundColumn>           
             </Columns>           
        </MasterTableView>
    </telerik:RadGrid>

For additional information, you can examine the Binding to SubObjects help topic.

Regards,
Mira
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
lina fetisova
Top achievements
Rank 1
answered on 10 Sep 2010, 04:34 AM
Mira, thank you very much, but i'm afraid it doesn't work for me - my SitesTree column is still empty =(
0
Mira
Telerik team
answered on 13 Sep 2010, 04:43 PM
Hello Lina,

Please bind the column to the corresponding property of the class:
public class NewsForSite
{
    private string sitesTree;
 
    public string SitesTree
    {
        get { return sitesTree; }
        set { sitesTree = value; }
    }
}

ASPX:

<telerik:GridBoundColumn DataField="SitesTree" HeaderText="Где опубликована" SortExpression="SitesTree"
    UniqueName="SitesTree" ReadOnly="true" AllowFiltering="true">
</telerik:GridBoundColumn>

I am also attaching a sample project demonstrating how this works.

I hope it helps.

Sincerely yours,
Mira
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
lina fetisova
Top achievements
Rank 1
answered on 14 Sep 2010, 03:41 AM
Mira!! Thank you very much!!! It works!!!! Thank you! =))))))))))
Tags
Grid
Asked by
lina fetisova
Top achievements
Rank 1
Answers by
lina fetisova
Top achievements
Rank 1
Mira
Telerik team
Share this question
or