troubleshooting Question

asp.net repeater

Avatar of ITsolutionWizard
ITsolutionWizardFlag for United States of America asked on
ASP.NETJSON
1 Comment1 Solution8 ViewsLast Modified:
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;
            Repeater1.DataBind();
        }




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


            </asp:Repeater>

[
{"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"}
]
ASKER CERTIFIED SOLUTION
David H.H.Lee
Digital Marketing (Hospitality)
Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros