473,382 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Binding Custom Collections to Datagrid

Using ASP.NET 1.1
----------------------

I have a custom collection of object that I'm binding to a datagrid. Each
of these objects have another collection inside them. I have a user control
that renders the nested collection into html table. See sample code below.

Now this binds fine and my sub collections are rendered fine by my user
control and list appears as it should. The problem is when I do paging. The
sub collections do not bind.

Any help would be appreciated.

Thank in advance,
Suresh.

<asp:datagrid id='dgTest' runat='server'>
<columns>
<asp:templatecolumn>
<itemtemplate>
<!-- Below is from the main collection -->
<%#DataBinder.Eval(Container.DataItem, "AssignmentStatus"))%>
<!-- Below is from the sub collection -->
<uc1:myusrctrl id="ucmyusrctrl" DataSourceItems='<%#
(MySubCollection) DataBinder.Eval(Container.DataItem, "Items") %>'
runat="server"></uc1:myusrctrl>
</itemtemplate>
</asp:templatecolumn>
</columns>
</asp:datagrid>
Sep 21 '06 #1
1 1904
Solved this issue.

2 - Things.

1. The actual setting of html inside my usercontrol was happening on
Page_Load of the user control and after I check 'If IsPostBack'. I should've
realized that clicking on a pager link is a postback operation.

2. The event order of page and user controls on postback. On postback the
user control is loaded before it's properties are allowed to be set. So even
when I removed 'If IsPostBack' it still had null for my sub object collection
property.
To solve this I simply moved the html rendering function inside the set
method of the property.

Now all is well.

Suresh.

"Suresh" wrote:
Using ASP.NET 1.1
----------------------

I have a custom collection of object that I'm binding to a datagrid. Each
of these objects have another collection inside them. I have a user control
that renders the nested collection into html table. See sample code below.

Now this binds fine and my sub collections are rendered fine by my user
control and list appears as it should. The problem is when I do paging. The
sub collections do not bind.

Any help would be appreciated.

Thank in advance,
Suresh.

<asp:datagrid id='dgTest' runat='server'>
<columns>
<asp:templatecolumn>
<itemtemplate>
<!-- Below is from the main collection -->
<%#DataBinder.Eval(Container.DataItem, "AssignmentStatus"))%>
<!-- Below is from the sub collection -->
<uc1:myusrctrl id="ucmyusrctrl" DataSourceItems='<%#
(MySubCollection) DataBinder.Eval(Container.DataItem, "Items") %>'
runat="server"></uc1:myusrctrl>
</itemtemplate>
</asp:templatecolumn>
</columns>
</asp:datagrid>
Sep 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: craig | last post by:
Assume that you would like to create a custom collection class that is: 1. Strongly-typed (only holds Customer objects) 2. Read-only (user cannot add Customer objects) 3. Able to be bound to...
5
by: Dalibor Kusic | last post by:
The DataTable contains, for example, only one column of lets say Person class. Person class has three fields, and a constructor that takes a single string and parses it over those three fields. ...
0
by: Simon Barbour | last post by:
Hi all, Tearing my hair out on this one so hopefully somebody can help. I have written a custom control to represent a button on a touchscreen EPoS (electronic point of sale) peice of...
0
by: berg | last post by:
All, I am binding an ArrayList full of custom objects to an DataGrid. The property in the custom class are all public. I define a DataGridTableStyle and set the MappingName to "ArrayList". I...
6
by: GingerNinja | last post by:
Hi Everybody, its about my 4th day on C# and all seems to be going smoothly however I've started to get into Datagrids and in particular binding data sources to them. In the documentation it says I...
1
by: Joe Jax | last post by:
I'm building my own version of a readonly DataTable, which needs to bind to various controls. My data table class has two main collections (CollectionBase instances): one of columns, one of rows,...
2
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid...
3
by: Just D | last post by:
Hi, If anybody needs to show some data retrieved from the database table, what method is more preferrable? 1. DataSet ds = ...; DataGrid.Data.Source.ds; DataGrid.Bind(); 2. Write a custom...
4
by: John Dalberg | last post by:
I noticed the starterkits timetracker & issue tracker load data from a database into custom collections (arraylists) which bind to a datagrid. What are the advantages of using custom collections...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.