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
0
Answer
how to bind multi level json data to a repeater
Tajkumar goud
9y
1.9k
1
Reply
I have to bind json data to a repeater i have found one method. i am able to bind the first level of json data. i am unable to bind the second level of json data repeater inside the repeater.
here is my json input
{
"apiAvailableBuses"
: [{
"droppingPoints"
:
null
,
"availableSeats"
:40,
"partialCancellationAllowed"
:
false
,
" arrivalTime"
:
"01:00 AM"
,
"cancellationPolicy"
:
" [{\"cutoffTime\":\"1\",\"refundInPercentage\":\"10\"},{\"cutoffTime\":\"2\",\"refundInPercentage\":\"50\"},{\"cutoffTime\":\"4\",\"refundInPercentage\":\"90\"}]"
,
"boardingPoints"
:[{
"time"
:
"07:40PM"
,
"location"
:
"K.P.H.B,Beside R.S Brothers"
,
"id"
:
"2238"
}],
"operatorName"
:
"Apple I Bus"
,
"departureTime"
:
"8:00 PM"
,
"mTicketAllowed"
:
false
,
"idProofRequired"
:
false
,
"serviceId"
:
"6686"
,
"fare"
:
"1000"
,
"busType"
:
"Hi-Tech A/c"
,
"routeScheduleId"
:
"6686"
,
"commPCT"
:9.0,
"operatorId"
:203,
"inventoryType"
:0}, {
"droppingPoints"
:
null
,
"availableSeats"
:41,
"partialCancellationAllowed"
:
false
,
"arrivalTime"
:
"06:00 AM"
,
"cancellationPolicy"
:
"[{\"cutoffTime\":\"1\",\"refundInPercentage\":\"10\"},{\"cutoffTime\":\"2\",\"refundInPercentage\":\"50\"},{\"cutoffTime\":\"4\",\"refundInPercentage\":\"90\"}]"
,
"boardingPoints"
:[{
"time"
:
"08:00PM"
,
"location"
:
"Punjagutta,"
,
"id"
:
"2241"
}],
"operatorName"
:
"Royalcoach Travels"
,
"departureTime"
:
"8:00 PM"
,
"mTicketAllowed"
:
false
,
"idProofRequired"
:
false
,
"serviceId"
:
"6736"
,
"fare"
:
"800"
,
"busType"
:
"VOLVO"
,
"routeScheduleId"
:
"6736"
,
"commPCT"
:9.0,
"operatorId"
:243,
"inventoryType"
:0}
Code
private
void
BindItemsInCart(List<apiAvailableBuses> ListOfSelectedProducts)
{
// The the LIST as the DataSource
this
.rptItemsInCart.DataSource = ListOfSelectedProducts;
// Then bind the repeater // The public properties become the columns of your repeater
this
.rptItemsInCart.DataBind(); }
public
void
getavailablebuses() {
string
url =
string
.Format(HttpContext.Current.Server.MapPath(
"files/getavailablebuses.json"
));
using
(WebClient client =
new
WebClient()) {
string
json = client.DownloadString(url); var result = JsonConvert.DeserializeObject<RootObject>(json);
string
mm = JObject.Parse(json).SelectToken(
"apiAvailableBuses"
).ToString();
// var boardingpoint = JObject.Parse(mm).SelectToken("boardingPoints").ToString();
var Availablebuses = JObject.Parse(json).SelectToken(
"apiAvailableBuses"
).ToString(); DataTable dt = (DataTable)JsonConvert.DeserializeObject(Availablebuses, (
typeof
(DataTable))); BindItemsInCart(result.apiAvailableBuses); }
public
class
apiresult {
public
string
message {
get
;
set
; }
public
string
success {
get
;
set
; } }
public
class
RootObject {
public
apiresult apiStatus;
public
List<apiAvailableBuses> apiAvailableBuses{
get
;
set
; }
// public string apiAvailableBuses { get; set; }
}
public
class
apiAvailableBuses
{
public
string
serviceId {
get
;
set
; }
public
string
fare {
get
;
set
; }
public
string
busType {
get
;
set
; }
public
string
departureTime {
get
;
set
; }
public
string
operatorName {
get
;
set
; }
public
string
cancellationPolicy {
get
;
set
; }
public
List<boardingpoints> boardingpoints {
get
;
set
; }
public
string
droppingPoints {
get
;
set
; }
public
string
inventoryType {
get
;
set
; }
public
string
routeScheduleId {
get
;
set
; }
public
int
availableSeats {
get
;
set
; }
public
string
arrivalTime {
get
;
set
; }
public
Boolean idProofRequired {
get
;
set
; }
public
Boolean partialCancellationAllowed {
get
;
set
; }
public
int
operatorId {
get
;
set
; }
public
double
commPCT {
get
;
set
; }
public
string
mTicketAllowed {
get
;
set
; } }
public
class
boardingpoints {
public
string
location {
get
;
set
; }
public
string
id {
get
;
set
; }
public
string
time {
get
;
set
; }
}
public
class
cancellationPolicy
{
public
string
cutoffTime {
get
;
set
; }
public
string
refundInPercentage {
get
;
set
; }
}
Here i am able to bind the data to the repeater i want to bind the boardingpoints data to the dropdownlist or another repeater inside that repeater how to do that please help me i am sleepless from so many days. Thank You in advance
Post
Reset
Cancel
Answers (
0
)
Next Recommended Forum
Cascading dropdown list
Editing values from DB