s_valmont — 2011-01-19T20:13:25-05:00 — #1
I have an ASP.NET ListView. Via ItemTemplate it renders as a table with columns ID and Name, and three rows of sample data:
ID | Name
1 | Name1
2 | Name2
3 | Name3
The data cells (i.e., 1, Name1, etc.) are all ASP.NET TextBoxes. In other words HTML inputs.
Is there a convenient, or at least most convenient, jQuery method for extracting the values from these data cells and packaging them into a JSON array that is sent AJAX-style to the server?
If it's not too much trouble I'd also really appreciate advice on how to add a row to the ListView without a postback.
nightstalker — 2011-01-19T23:29:08-05:00 — #2
Well the only option you really have is to create a foreach loop and loop through each textbox yourself and append it to a string, and that string should be in JSON format when done. So it is a rather manual process.
As for adding an item with jquery, what you would need to do here is inspect the output of your listview as html. This will depend on your template, etc. But you mentioned a table, so I am going with that. You will need to replicate the item template in your script. Then using jQuery to target that table and append the html you created into the table.
s_valmont — 2011-01-20T12:35:28-05:00 — #3
Thanks. Is there any chance you have a useful link for how to write this loop logic in jQuery?