473,508 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

binding a list within a list to gridview

1 New Member
Hello ,

I have the following code:
Expand|Select|Wrap|Line Numbers
  1. public class abc
  2. {
  3. public string customername { get; set; }
  4. public List<def> DEF { get; set; }
  5. }
  6.  
  7.  
  8. public class def
  9. {
  10. public string materialcode { get; set; }
  11. }
  12.  
  13. on page load 
  14.  
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17. List<abc> test1 = new List<abc>();
  18. List<def> test2 = new List<def>();
  19.  
  20. test2.Add(new def() {materialcode="something" });
  21. test1.Add(new abc(){customername="anything", DEF=test2});
  22. GridView1.DataSource = test1;
  23. GridView1.DataBind();
  24. }
  25.  
and in the ascx file

Expand|Select|Wrap|Line Numbers
  1. <asp:GridView ID="GridView1" runat="server">
  2.  
  3. <Columns>
  4. <asp:TemplateField HeaderText="Charge Code">
  5. <ItemTemplate>
  6. <asp:Label ID="lblchargecode" runat="server" Text='<%#((def)Eval("DEF"))[0].materialcode %>'></asp:Label>
  7. </ItemTemplate>
  8. </asp:TemplateField>
  9.  
  10. </Columns>
  11. </asp:GridView>
  12.  
  13.  
I am getting an error message stating that def is not a member , if i am missing an assembly reference.

Please help me bind it to the gridview. Its very urgent

Thanks all.
Mar 15 '11 #1
1 1744
samueal
8 New Member
Where the error is? Give a different name for class def
May 19 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1704
by: Antonio Gulli | last post by:
Hi, i need to create a list of list in STL where each element can move from a given list level to the adjacent list. i.e. | -> x -> y -> z | -> a -> b can be modified to
7
3176
by: gn | last post by:
Hi have a dropdown list within a datagrid, based on what is selected in the list I want to populate another dropdownlist, the code to populate the dropdownlists is not the problem, my problem is...
2
1821
by: Ben Bush | last post by:
I have a lis: ,,,,,] I want a code to test when the difference between the first element in the list of list is equal to or larger than 6, then move the previous lists to the end of the list....
7
1596
by: Steven Bethard | last post by:
Tom Anderson <twic@urchin.earth.li> wrote: > Sounds good. More generally, i'd be more than happy to get rid of list > comprehensions, letting people use list(genexp) instead. That would >...
4
12021
by: colson | last post by:
Hi, If I have a class A, and a List<List<object>> containing instances of A. How do I explicitly cast List<List<object>> as List<List<A>>?
4
33110
by: Sin Jeong-hun | last post by:
List<List<T>a=param; List<List<T>b=a; If I change b, then a is get changed. I want another copy of a, that is completely independent of a. I used double-nested for loop to copy each element...
12
3928
by: joshd | last post by:
Hello, Im sorry if this question has been asked before, but I did search before posting and couldnt find an answer to my problem. I have two classes each with corresponding linked lists, list1...
3
2405
by: Riccardo Murri | last post by:
Hello, I have some code that stops when trying to find a graph in a list of similar graphs:: (Pydb) list 110 try: 111 canonical = self.base 112 except ValueError: 113 ...
5
14156
by: DotNetNewbie | last post by:
Hi, It is not possible to bind a Generic.List collection to a repeater I guess huh? I am getting this error: An invalid data source is being used for rpCategories. A valid data source must...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7133
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7405
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5643
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3214
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.