locked
Jquery repeater plugin RRS feed

  • Question

  • User-1399352090 posted

    Hello,

    i want to use jquery repeater in my asp.net website. because this plugin doing exaclty what i need it.

    but i'm very new with jason and jquery data. could any one help me to save  jason data (customer data) in to data base using  c# class objects

    here is the plugin which is using..

    http://briandetering.net/repeater

    Appreaciate for quick and best response

    Saturday, December 10, 2016 9:38 PM

Answers

  • User-1838255255 posted

    Hi smd_yasin,

    According to your description, I suggest you use JavaScriptSerializer convert json data to c# object. I make a sample, you can refer to Sample Code:

    protected void Page_Load(object sender, EventArgs e)
        {
            string jsonarry = "[{ID:'01',Name:'xxl'},{ID:'01',Name:'xxl'},{ID:'01',Name:'xxl'},{ID:'01',Name:'xxl'}]";
            JavaScriptSerializer json = new JavaScriptSerializer();
            List<User> list = json.Deserialize<List<User>>(jsonarry);
            foreach (var item in list)
            {
                Response.Write(item.ID+"</br>"+item.Name+"</br>"+item.Sex);
            }
    // you can save it in database } public class User { public int ID { get; set; } public string Name { get; set; } public string Sex { get; set; } }

    Best Regards,

    Eric Du

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, December 11, 2016 5:29 AM

All replies

  • User-1838255255 posted

    Hi smd_yasin,

    According to your description, I suggest you use JavaScriptSerializer convert json data to c# object. I make a sample, you can refer to Sample Code:

    protected void Page_Load(object sender, EventArgs e)
        {
            string jsonarry = "[{ID:'01',Name:'xxl'},{ID:'01',Name:'xxl'},{ID:'01',Name:'xxl'},{ID:'01',Name:'xxl'}]";
            JavaScriptSerializer json = new JavaScriptSerializer();
            List<User> list = json.Deserialize<List<User>>(jsonarry);
            foreach (var item in list)
            {
                Response.Write(item.ID+"</br>"+item.Name+"</br>"+item.Sex);
            }
    // you can save it in database } public class User { public int ID { get; set; } public string Name { get; set; } public string Sex { get; set; } }

    Best Regards,

    Eric Du

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, December 11, 2016 5:29 AM
  • User-1399352090 posted

    Hello Eric,

    I have used Serializer but i  have issue with with my json fomat

    im getting below json string/array.

    {"customer":[{"name":"harry","deliverydate":"10-1-2016",,"dress":[{"fornt":"22","type":"Shirt"}],"totalPaid":"22.99"}]}

    with this i'm getting zero count in list

    how can convert into proper json fomat?

    Monday, December 12, 2016 12:27 PM
  • User1771544211 posted

    Hi smd_yasin,

    ":"10-1-2016",,"dress"

    There is a syntax error in your json string, you have an extra comma in your json string, please remove it.

    {"customer":[{"name":"harry","deliverydate":"10-1-2016","dress":[{"fornt":"22","type":"Shirt"}],"totalPaid":"22.99"}]}

    And you can check your json string using the json online parser : http://json.parser.online.fr/

    Best Regards,

    Jean

    Thursday, December 15, 2016 7:21 AM