Hi
I want to display data returned by Api in a repeater. I want to display id,title.
C#
"kind": "youtube#videoCategoryListResponse",
"etag": "fIIv2-q7-AkaOeJf0LPrlnu-0As",
"items": [
{
"kind": "youtube#videoCategory",
"etag": "grPOPYEUUZN3ltuDUGEWlrTR90U",
"id": "1",
"snippet": {
"title": "Film & Animation",
"assignable": true,
"channelId": "UCBR8-60-B28hp2BmDPdntcQ"
}
},
{
"kind": "youtube#videoCategory",
"etag": "Q0xgUf8BFM8rW3W0R9wNq809xyA",
"id": "2",
"snippet": {
"title": "Autos & Vehicles",
"assignable": true,
"channelId": "UCBR8-60-B28hp2BmDPdntcQ"
}
},Thanks

Sachin SinghRank #66 · 26.2K reputationPosted Feb 2, 2023, 7:59 AM EST
First desrialize the bind the desired proerties
// Root myDeserializedClass = JsonConvert.DeserializeObject(myJsonResponse); public class Item { public string kind { get; set; } public string etag { get; set; } public string id { get; set; } public Snippet snippet { get; set; } } public class Root { public string kind { get; set; } public string etag { get; set; } public List items { get; set; } } public class Snippet { public string title { get; set; } public bool assignable { get; set; } public string channelId { get; set; } } public class MyModel { public string id { get; set; } public string title { get; set; } }List list= new List(); foreach(var obj in myDeserializedClass.Items) { MyModel md= new MyModel() { id=obj.id, title =obj.title } list.Add(md); } RepeaterID.DataSource=list; RepeaterID.DataBind();