Link to home
Create AccountLog in
Avatar of ITsolutionWizard
ITsolutionWizardFlag for United States of America

asked on repeater

The following code that trying to use Repeater is not working. But "Response.Write" is working and return the data I want.

When I try to use _Data to repeater, I see the following error.
Cannot deserialize the current JSON array (e.g. [1,2,3]) into

I believe it is because the Json string does not have root before [ sign, but I do not know how to fix it.

public class Rootobject
            public string Make { get; set; }
            public string Model { get; set; }
        protected void Page_Load(object sender, EventArgs e)
            xml.Text = GetFleetList("Tow","xml");
            json.Text = GetFleetList("Tow", "json");

            var x = GetFleetList("Tow", "json");

            var _Data = Newtonsoft.Json.JsonConvert.DeserializeObject <List<Rootobject>>(x);

            foreach (Rootobject item in _Data)
                Response.Write(item.Make+ ":" + item.Model + "<br>");
            Repeater1.DataSource = _Data;

 <asp:Repeater runat="server" ID="Repeater1">
                    <%# DataBinder.Eval(Container, "Make")%>                    


Open in new window

{"FleetID":6045,"Make":"Kenworth","Model":"T800","FleetMasterType":"Tow","FleetClassType":"Tow Truck","FleetClassSubType":"Heavy Duty Wrecker"},{"FleetID":6046,"Make":"Freightliner","Model":"Business Class M2 106","FleetMasterType":"Tow","FleetClassType":"Tow Truck","FleetClassSubType":"Medium Duty Trucks Roll-back"},{"FleetID":6047,"Make":"Freightliner","Model":"Business Class M2 106","FleetMasterType":"Tow","FleetClassType":"Tow Truck","FleetClassSubType":"Heavy Duty Trucks Wrecker"},{"FleetID":6048,"Make":"Freightliner","Model":"Business Class M2 106","FleetMasterType":"Tow","FleetClassType":"Tow Truck","FleetClassSubType":"Medium Duty Trucks Roll-back"},{"FleetID":6049,"Make":"Peterbilt","Model":"389","FleetMasterType":"Tow","FleetClassType":"Tow Truck","FleetClassSubType":"Heavy Duty Wrecker"},{"FleetID":6050,"Make":"GMC","Model":"5500","FleetMasterType":"Tow","FleetClassType":"Tow Truck","FleetClassSubType":"Medium Duty Trucks Wrecker"},
{"FleetID":6051,"Make":"International","Model":"DT4300","FleetMasterType":"Tow","FleetClassType":"Tow Truck","FleetClassSubType":"Medium Duty Trucks Wrecker"},
{"FleetID":6057,"Make":"Paccar","Model":"T370","FleetMasterType":"Tow","FleetClassType":"Tow Truck","FleetClassSubType":"Heavy Duty Trucks Car Carrier"}

Open in new window

Avatar of David H.H.Lee
David H.H.Lee
Flag of Malaysia image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account