如何在ASP.NET,VB.NET中读取json文件并将其绑定到gridview [英] How can I read json file and bind it to gridview in ASP.NET, VB.NET

查看:170
本文介绍了如何在ASP.NET,VB.NET中读取json文件并将其绑定到gridview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我必须阅读json文件并使用vb.net将其绑定到asp.net中的gridview

必须通过添加或删除实体来更新json对象



请帮忙,我一直在谷歌搜索过去3天,我无法得到任何帮助





谢谢

Chaitanya Basava Kumar



我尝试了什么:



我在谷歌搜索过,我找不到任何有用的东西。请帮助

Hi,

I have to read json file and bind it to gridview in asp.net using vb.net
And also have to update the json object by adding or removing the entities

Please help in that, I have been searching in google for the past 3 days, I couldn't get any help


Thanks
Chaitanya Basava Kumar

What I have tried:

I have searched in google, I couldn't find anything helpful. Please hel

推荐答案

有一个名为 Newtonsoft JSON.Net 的库,您可以使用它来轻松地序列化和串行化JSON字符串来回到C#/ VB.NET对象。看一下这篇文章,例如:将JSON转换为DataTable使用C#或VB.Net - blakepell.com [ ^ ]



想要将JSON文件流式化为字符串,然后将其转换为将JSON字符串转换为对象。该对象可以是一个集合,数组或数据表,您可以在其中用作GridView的数据源。



修改底层JSON文件是另一个故事,因为您需要将GridView中的数据解析回JSON对象或JArray,进行修改,然后将更改写回文件。这是一个例子: https://www.c -sharpcorner.com/article/crud-operation-with-json-file-data-in-c-sharp/ [ ^ ]



上面的例子是用C#编写的。如果您在解释代码时遇到困难,可以使用此在线免费转换工具将C#转换为VB.NET: Code Converter C#to VB and VB到C# - Telerik [ ^ ]
There's a library called Newtonsoft JSON.Net that you can use to easily serialize and serialize JSON string back and forth to C#/VB.NET object. Take a look at this article for example: Convert JSON to a DataTable with C# or VB.Net - blakepell.com[^]

The idea if to stream your JSON file to a string, and then convert that JSON string into an object. This object can be a collection, array or datatable in which you can use as data source for your GridView.

Modifying the underlying JSON file is another story as you need to parse the data from your GridView back to a JSON object or JArray, do the modification and then write the changes back to a file. Here's one example: https://www.c-sharpcorner.com/article/crud-operation-with-json-file-data-in-c-sharp/[^]

The example above is written in C#. If you are having a hard time interpreting the code, you can use this online free converter tool to translate C# to VB.NET: Code Converter C# to VB and VB to C# – Telerik[^]


这篇关于如何在ASP.NET,VB.NET中读取json文件并将其绑定到gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆