Last post Aug 12, 2019 09:05 AM by PatriceSc
Aug 09, 2019 09:56 AM|binustrat|LINK
I am using FOR JSON AUTO keyword in my procedure select statement and I am getting output like JSON. My question is how can I handle it in c#. This is a list of data and I want to show in the grid. Below giving my code.
SELECT t.ID,t_type.[Name],t.Task_No, t.Task_Title, t.Due_On, t.Assigned_By, Assigned_On FROM task t inner join Task_Type_MF t_type ON t.Task_Type_ID=t_type.ID
WHERE t.Assigned_To=@Id FOR JSON AUTO
Out i am getting
How can i manage this output in c# to list in grid
Aug 09, 2019 10:59 AM|PatriceSc|LINK
Some more context could help.
Given the current context, it seems you need to return a raw json string from your api: see https://forums.asp.net/t/1844684.aspx?Web+api+method+return+json+in+string so
that it could be then processed on the client side as the result of your Ajax call.
If your intent is really to render a list to grid server side using C# code then it seems using FOR JSON is perhaps not the best choice and I'm not even sure it should be in the web api forum.
Rather than giving a wrong starting point, sometimes it is just best to tell in plain English so that one can suggest how to do that rather than giving a direction which is not well suited to your actual intent.
Aug 09, 2019 12:58 PM|AddWeb Solution|LINK
please refer below link for how you can covert your json string to c#. after you get data in your c# model then yes you can easily bind with grid.
Aug 12, 2019 09:05 AM|PatriceSc|LINK
I see no point in serializing data to JSON on the db side to deserialize them on the web server side. It seems it would make more sense to just read them as usual...
I would use FOR JSON if I want my web server to send this back directly as a raw json payload to the browser side.