
I want .net code the aboce grid format

I want .net code the aboce grid format
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sreenath KappoorRank #655 · 3.7K reputationPosted Feb 6, 2025, 1:51 AM EST
Hello,
Try using rowspan and colspan. they are attributes used in HTML tables to define how many rows or columns a cell should span (occupy) within the table.
rowspan: This attribute allows a table cell to span multiple rows. It is used to make a cell stretch vertically across several rows. For example, if you want a cell to span two rows, you would set rowspan="2".
colspan: This attribute allows a table cell to span multiple columns. It is used to make a cell stretch horizontally across several columns. For example, if you want a cell to span three columns, you would set colspan="3".
Tuhin PaulRank #7 · 71.9K reputationPosted Feb 6, 2025, 2:09 PM EST
Part - 1
This implementation includes:
1. A `StudentMarks` class that defines the data model
2. An ASPX page with a GridView control and CSS styling
3. A code-behind file that populates the grid with data
public class StudentMarks { public int IdNo { get; set; } public string StudentName { get; set; } // External Theory (50%) public decimal ExternalTheory { get; set; } // Internal Theory + Practical (50%) public decimal SemFinal { get; set; } public decimal Quiz { get; set; } public decimal MidSem { get; set; } public decimal AssignmentRecord { get; set; } public decimal FinalPractical { get; set; } // Totals public decimal TotalInternalTheoryPractical { get; set; } public decimal TotalTheoryPractical { get; set; } public decimal GradePoint { get; set; } // Attendance public decimal TheoryAttendance { get; set; } public decimal PracticalAttendance { get; set; } public string Remarks { get; set; } }Student Marks Grid .grid-container { margin: 20px; font-family: Arial, sans-serif; } .grid-header { background-color: #f0f0f0; font-weight: bold; } .grid-row:nth-child(even) { background-color: #f9f9f9; } .grid-cell { padding: 8px; border: 1px solid #ddd; } ' CssClass="grid-cell"> ' CssClass="grid-cell"> ' CssClass="grid-cell"> ' CssClass="grid-cell"> ' CssClass="grid-cell"> ' CssClass="grid-cell"> ' CssClass="grid-cell">using System; using System.Collections.Generic; using System.Web.UI; public partial class StudentMarksGrid : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindGrid(); } } private void BindGrid() { List marksList = new List { new StudentMarks { IdNo = 1, StudentName = "Student 1", ExternalTheory = 39.50M, SemFinal = 6.50M, Quiz = 17.17M, MidSem = 7.50M, AssignmentRecord = 7.75M, TotalInternalTheoryPractical = 38.92M, TotalTheoryPractical = 78.42M, GradePoint = 7.84M, TheoryAttendance = 100.00M, PracticalAttendance = 100.00M, Remarks = "PASS" } // Add more student records as needed }; MarksGridView.DataSource = marksList; MarksGridView.DataBind(); } }The grid will display student marks with proper formatting and column headers matching your image. You can further customize the appearance by modifying the CSS classes and GridView properties.
Tuhin PaulRank #7 · 71.9K reputationPosted Feb 6, 2025, 2:16 PM EST
Part - 2
The grid will display student marks in a format similar to your image
namespace StudentGradeTracker.Models { public class StudentMarks { public int IdNo { get; set; } public string StudentName { get; set; } = string.Empty; // External Theory (50%) public decimal ExternalTheory { get; set; } // Internal Theory + Practical (50%) public decimal SemFinal { get; set; } public decimal Quiz { get; set; } public decimal MidSem { get; set; } public decimal AssignmentRecord { get; set; } public decimal FinalPractical { get; set; } // Calculated Properties public decimal TotalInternalTheoryPractical => SemFinal + Quiz + MidSem + AssignmentRecord + FinalPractical; public decimal TotalTheoryPractical => ExternalTheory + TotalInternalTheoryPractical; public decimal GradePoint => TotalTheoryPractical / 10; // Attendance public decimal TheoryAttendance { get; set; } public decimal PracticalAttendance { get; set; } public string Remarks => DetermineRemarks(); private string DetermineRemarks() { if (TotalTheoryPractical >= 40 && TheoryAttendance >= 75 && PracticalAttendance >= 75) return "PASS"; return "FAIL"; } } }namespace StudentGradeTracker.Services { public interface IStudentMarksService { IEnumerable GetAllStudentMarks(); } }namespace StudentGradeTracker.Services { public class StudentMarksService : IStudentMarksService { public IEnumerable GetAllStudentMarks() { // Sample data - in real application, this would come from a database return new List { new StudentMarks { IdNo = 1, StudentName = "Student 1", ExternalTheory = 39.50M, SemFinal = 6.50M, Quiz = 17.17M, MidSem = 7.50M, AssignmentRecord = 7.75M, FinalPractical = 7.75M, TheoryAttendance = 100.00M, PracticalAttendance = 100.00M }, new StudentMarks { IdNo = 2, StudentName = "Student 2", ExternalTheory = 47.00M, SemFinal = 8.00M, Quiz = 17.83M, MidSem = 8.50M, AssignmentRecord = 8.00M, FinalPractical = 7.25M, TheoryAttendance = 80.00M, PracticalAttendance = 80.00M } }; } } }using Microsoft.AspNetCore.Mvc; using StudentGradeTracker.Services; namespace StudentGradeTracker.Controllers { public class MarksController : Controller { private readonly IStudentMarksService _marksService; public MarksController(IStudentMarksService marksService) { _marksService = marksService; } public IActionResult Index() { var marks = _marksService.GetAllStudentMarks(); return View(marks); } } }@model IEnumerable @{ ViewData["Title"] = "Student Marks"; } Student Marks I.D.NO. NAME OF THE STUDENT External Theory (50%) Internal Theory + Practical (50%) Total Internal Total Theory + Practical Grade Point ATTENDANCE Remarks Sem Final Quiz Mid Sem Assignment Final Practical Theory Practical @foreach (var item in Model) { @item.IdNo @item.StudentName @item.ExternalTheory.ToString("F2") @item.SemFinal.ToString("F2") @item.Quiz.ToString("F2") @item.MidSem.ToString("F2") @item.AssignmentRecord.ToString("F2") @item.FinalPractical.ToString("F2") @item.TotalInternalTheoryPractical.ToString("F2") @item.TotalTheoryPractical.ToString("F2") @item.GradePoint.ToString("F2") @item.TheoryAttendance.ToString("F2")% @item.PracticalAttendance.ToString("F2")% @item.Remarks } @section Styles { .table-responsive { overflow-x: auto; } .table th, .table td { vertical-align: middle; text-align: center; } .thead-dark th { background-color: #343a40; color: white; } }var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllersWithViews(); builder.Services.AddScoped(); var app = builder.Build(); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.MapControllerRoute( name: "default", pattern: "{controller=Marks}/{action=Index}/{id?}"); app.Run();