Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7769197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:05:56+00:00 2026-06-01T16:05:56+00:00

I have a class named Student public class Student { public string Name {

  • 0

I have a class named Student

public class Student
{
    public string Name { get; set; }
    public List<int> Marks { get; set; }
    public Student()
    {
    }
}

and I need to bind a list of Student to GridView

        List<Student> StudentList = new List<Student>();

        Student stud = new Student();
        stud.Name = "Scott";
        List<int> marks = new List<int>();
        marks.Add(10); 
        marks.Add(20); 
        marks.Add(30);
        stud.Marks = marks;

        StudentList.Add(stud);

        Student stud1 = new Student();
        stud1.Name = "Jon";
        List<int> marks1 = new List<int>();
        marks1.Add(10);
        marks1.Add(20);
        marks1.Add(30);
        stud1.Marks = marks1;

        StudentList.Add(stud1);

        GridView1.DataSource = StudentList;
        GridView1.DataBind();

The gridview shows the name field only. how I can show the list of marks also with name field. (In this all the students have same number of marks, means sometimes 3, or sometimes 5. etc.)

I need show gridview like this

Name    Mark1  Mark2 Mark3 
Scott   10     20    30
Jon     10     20    30
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T16:05:58+00:00Added an answer on June 1, 2026 at 4:05 pm

    Example:

    <asp:GridView ID="grid1" runat="server" AutoGenerateColumns="false" Width="100%">
        <Columns>
            <asp:BoundField DataField="Name" HeaderText="Name" />
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:GridView ID="grid2" runat="server" AutoGenerateColumns="False" Width="100%">
                    <Columns>
                        <asp:BoundField DataField="Mark" HeaderText="Mark" />
                    </Columns>
                </asp:GridView>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    

    Code:

    protected override void OnInit(EventArgs e)
    {
      grid1.RowDataBound += grid1_RowDataBound;
    }
    
    void grid1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
      var grid2 = (GridView)e.Item.FindControl("grid2");
      grid2.DataSource = StudentList.Where(w => w.Name = (e.Item.DataItem as Student).Name);
      grid2.Bind();
    }
    

    I do not test it

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have class student : public class Student { public string Name { get;
Suppose I have two classes: public class Student { public int Id {get; set;}
i have these models: public class Student { public int Id { get; set;
Given the classes: public class Person { public string Name { get; set; }
Say i have a object like this public class Student{ public IList<Coursework> Courseworks{get;set;} public
Class Student { String Name {get; set} //Extended property of the student School Shooling
I have this schema : public class Student { public String name; public School
I have a document entity Student public class Student { public string Id {
I have these two class(table) @Entity @Table(name = course) public class Course { @Id
I have an object that looks something like this: public class Student { public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.