Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
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 Assemblies
.NET Core
.NET Standard
Active Directory
ADO.NET
Agile Development
AJAX
Alexa Skills
Algorithms in C#
Android
Angular
Architecture
ArcObject
Artificial Intelligence
ASP.NET
ASP.NET Core
Augmented Reality
Aurelia
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blockchain
Bootstrap
Bot Framework
Business
C#
C# Corner
C, C++, MFC
Career Advice
Chapters
CIO
Cloud
COBOL.NET
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Cortana Development
Cryptocurrency
Cryptography
Crystal Reports
Current Affairs
Custom Controls
Cyber Security
Data Mining
Databases & DBA
Design Patterns & Practices
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
Expression Studio
F#
Files, Directory, IO
Games Programming
GDI+
General
Generative Engine Optimization (GEO)
Google Cloud
Google Development
Graphics Design
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Internet & Web
Internet of Things
Ionic
iOS
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
kotlin
Leadership
Learn .NET
LightSwitch
LINQ
Machine Learning
Microsoft 365
Microsoft Office
Microsoft Phone
Mobile Development
Multithreading
Nano Banana
NetBeans
Networking
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Power BI
Printing in C#
Products
Progressive Web Apps
Project Management
Python
Q#
QlikView
R
React
Reports using C#
Robotics & Hardware
Ruby on Rails
Salesforce
Security
Servers
SharePoint
SignalR
Silverlight
Smart Devices
Software Testing
SQL Language
SQL Server
Startups
String in C#
Swift
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
WCF
Wearables
Web Development
Web Services
Web3
Windows 10
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML Standard
XML
XNA
XSharp
Register
Login
3
Answers
[How] MVC multiple grid with different data
Bryan Gomez
7y
157
0
1
Compact Framework
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
)
Related Discussion