Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Core
.NET MAUI
.NET Standard
Active Directory
ADO.NET
Agile Development
AI
AJAX
AlbertAGPT
Alchemy
Alexa Skills
Algorand
Algorithms in C#
Android
Angular
ArcObject
ASP.NET
ASP.NET Core
Augmented Reality
Avalanche
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blazor
Blockchain
Bootstrap
Bot Framework
Business
Business Intelligence(BI)
C#
C# Corner
C# Strings
C, C++, MFC
Career Advice
Careers and Jobs
Chapters
ChatGPT
Cloud
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Copilot
Cortana Development
Cosmos DB
Cryptocurrency
Cryptography
Crystal Reports
CSS
Current Affairs
Custom Controls
Cyber Security
Data Mining
Data Science
Databases & DBA
Databricks
Design Patterns & Practices
DevExpress
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
F#
Files, Directory, IO
Flutter
Games Programming
GDI+
General
Generative AI
GO
Google Cloud
Google Development
Graphics Design
Graphite Studio
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Infragistics
Internet & Web
Internet of Things
Ionic
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
Kotlin
Langchain
Leadership
Learn .NET
Learn iOS Programming
LINQ
Machine Learning
Metaverse
Microsoft 365
Microsoft Fabric
Microsoft Office
Microsoft Phone
Microsoft Teams
Mobile Development
MongoDB
MuleSoft
MySQL
NEAR
NetBeans
Networking
NFT
NoCode LowCode
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Polygon
PostgreSQL
Power Apps
Power Automate
Power BI
Power Pages
Printing in C#
Products
Progress
Progressive Web Apps
Project Management
Public Speaking
Python
Q#
QlikView
Quantum Computing
R
React
React Native
Reports using C#
Robotics & Hardware
RPA
Ruby on Rails
RUST
Salesforce
Security
Servers
ServiceNow
SharePoint
Sharp Economy
SignalR
Smart Devices
Snowflake
Software Architecture/Engineering
Software Testing
Solana
Solidity
Sports
SQL
SQL Server
Startups
Stratis Blockchain
Swift
SyncFusion
Threading
Tools
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
Vue.js
WCF
Wearables
Web API
Web Design
Web Development
Web3
Windows
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML
XML
XNA
XSharp
Register
Login
3
Answers
[How] MVC multiple grid with different data
Bryan Gomez
7y
4.1k
1
Reply
I need some help on how to achived the multiple grid in my mvc razor form with different data. Currently I only have 1 grid.
Here's my Model:
namespace
wmssoft_srm.Models
{
public
class
ServiceList
{
public
List<ServiceListData> GetData(DataTable oDT)
{
try
{
List<ServiceListData> slData =
new
List<ServiceListData>();
for
(
int
i = 0; i < oDT.Rows.Count; i++)
{
/*Parse date*/
string
date = oDT.Rows[i][
"ORDDATE"
].ToString();
string
result = DateTime.ParseExact(date,
"yyyyMMdd"
, CultureInfo.InvariantCulture).ToString(
"yyyy-MM-dd"
);
ServiceListData sl =
new
ServiceListData();
sl.date = Convert.ToDateTime(result);
sl.so_no = oDT.Rows[i][
"ORDNUMBER"
].ToString();
sl.serial = oDT.Rows[i][
"SERIAL"
].ToString();
sl.status = oDT.Rows[i][
"STATUS"
].ToString();
sl.technician = oDT.Rows[i][
"TECH"
].ToString();
slData.Add(sl);
}
return
slData;
}
catch
(Exception)
{
throw
new
NotImplementedException();
}
}
}
public
class
ServiceListData
{
public
DateTime date {
get
;
set
; }
public
string
so_no {
get
;
set
; }
public
string
serial {
get
;
set
; }
public
string
status {
get
;
set
; }
public
string
technician {
get
;
set
; }
}
public
enum
Status
{
Open,
Close
}
}
And in my controller:
My problem is that, how can I call the 2nd grid from my controller?
public
ActionResult Index()
{
WCF_Service.InterfaceClient wmsSR =
new
WCF_Service.InterfaceClient();
DataSet dsl =
new
DataSet();
DataSet dsO =
new
DataSet();
string
a =
"ValidateCredentials"
;
string
b =
"~~ ~~ ~~"
;
b = wmsSR.fCallService(
"GetServiceList"
, b,
ref
dsl,
ref
dsO);
if
(b ==
"OK ~~"
)
{
if
(dsO.Tables[0].Rows.Count > 0)
{
DataTable oDT =
new
DataTable();
oDT = dsO.Tables[0];
wmssoft_srm.Models.ServiceList slData =
new
Models.ServiceList();
var myList = slData.GetData(oDT);
return
View(myList);
}
}
return
View();
}
Also this is my View, the allJobs is my 2nd grid. The myJobs is my 1st grid which is working as expected based from my controller.
@model List<wmssoft_srm.Models.ServiceListData>
@using GridMvc.Html
<
div
id
=
"Tabs"
role
=
"tabpanel"
>
<!-- Nav tabs -->
<
ul
class
=
"nav nav-tabs"
role
=
"tablist"
>
<
li
class
=
"active"
>
<
a
href
=
"#tabs-1"
aria-controls
=
"tabs-1"
role
=
"tab"
data-toggle
=
"tab"
>
My Jobs
</
a
>
</
li
>
<
li
>
<
a
href
=
"#tabs-2"
aria-controls
=
"tabs-2"
role
=
"tab"
data-toggle
=
"tab"
>
All Jobs
</
a
>
</
li
>
<
li
>
<
a
href
=
"#tabs-3"
aria-controls
=
"tabs-3"
role
=
"tab"
data-toggle
=
"tab"
>
Unallocated Jobs
</
a
>
</
li
>
</
ul
>
<!-- Tab panes -->
<
div
class
=
"tab-content"
style
=
"padding-top: 20px"
>
<
div
role
=
"tabpanel"
class
=
"tab-pane active"
id
=
"tabs-1"
>
@Html.Grid(Model).Columns(
columns
=
>
{
columns.Add(
foo
=
>
foo.date).Titled("Date").SetWidth(30).Sortable(true); /*BTG 11/10/2017 - old .Filterable(true)*/
columns.Add(
foo
=
>
foo.so_no).Titled("SO No.").SetWidth(30).Sortable(true); //.Filterable(true);
columns.Add(
foo
=
>
foo.serial).Titled("Serial").SetWidth(30).Sortable(true); //.Filterable(true);
columns.Add(
foo
=
>
foo.status).Titled("Status").SetWidth(30).Sortable(true); //.Filterable(true);
columns.Add(
foo
=
>
foo.technician).Titled("Technician").SetWidth(30).Sortable(true); //.Filterable(true);
}).WithPaging(5).Named("myJob")
</
div
>
<
div
role
=
"tabpanel"
class
=
"tab-pane"
id
=
"tabs-2"
>
@Html.Grid(Model).Columns(
columns
=
>
{
columns.Add(
foo
=
>
foo.date).Titled("Date").SetWidth(30).Sortable(true); /*BTG 11/10/2017 - old .Filterable(true)*/
columns.Add(
foo
=
>
foo.so_no).Titled("SO No.").SetWidth(30).Sortable(true); //.Filterable(true);
columns.Add(
foo
=
>
foo.serial).Titled("Serial").SetWidth(30).Sortable(true); //.Filterable(true);
columns.Add(
foo
=
>
foo.status).Titled("Status").SetWidth(30).Sortable(true); //.Filterable(true);
columns.Add(
foo
=
>
foo.technician).Titled("Technician").SetWidth(30).Sortable(true); //.Filterable(true);
}).WithPaging(5).Named("allJobs")
</
div
>
</
div
>
</
div
>
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
How to disable View Page Source in Browser?
How to Send mail automatically thru external javascript ?