Hi paulsb011,
Use WebClient class to read the Json from URL.
For more details refer below article.
Read (Parse) JSON data from URL in ASP.Net using C# and VB.Net
Then convert the Json to generic list of class object and populate the DropDownList.
Please refer below code.
HTML
<asp:DropDownList runat="server" ID="ddlNames">
</asp:DropDownList>
Namespaces
C#
using System.Net;
using System.Web.Script.Serialization;
VB.Net
Imports System.Net
Imports System.Web.Script.Serialization
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
string json = (new WebClient()).DownloadString("https://workforcedeveloper-api.hcso.fr.co.hennepin.mn.us/Directory");
JavaScriptSerializer serializer = new JavaScriptSerializer();
List<Person> persons = serializer.Deserialize<List<Person>>(json);
ddlNames.DataSource = (from p in persons
select string.Format("{0} {1} {2}", p.firstName, p.middleName, p.lastName));
ddlNames.DataBind();
}
public class PhoneNumber
{
public string phoneType { get; set; }
public string phoneNumber { get; set; }
}
public class Person
{
public string firstName { get; set; }
public string middleName { get; set; }
public string lastName { get; set; }
public string email { get; set; }
public string currentUnit { get; set; }
public string currentRank { get; set; }
public List<PhoneNumber> phoneNumbers { get; set; }
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim json As String = (New WebClient()).DownloadString("https://workforcedeveloper-api.hcso.fr.co.hennepin.mn.us/Directory")
Dim serializer As JavaScriptSerializer = New JavaScriptSerializer()
Dim persons As List(Of Person) = serializer.Deserialize(Of List(Of Person))(json)
ddlNames.DataSource = (From p In persons Select String.Format("{0} {1} {2}", p.firstName, p.middleName, p.lastName))
ddlNames.DataBind()
End Sub
Public Class PhoneNumber
Public Property phoneType As String
Public Property phoneNumber As String
End Class
Public Class Person
Public Property firstName As String
Public Property middleName As String
Public Property lastName As String
Public Property email As String
Public Property currentUnit As String
Public Property currentRank As String
Public Property phoneNumbers As List(Of PhoneNumber)
End Class
Screenshot