Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Adding mulitple items into listview

$
0
0

Hi guys,

I am new to Xamarin forms and trying to pass json values into a listview after fetching it. I have no luck. If anyone have any idea it would be great, below is my code. It's my first time using listview, hope someone could teach, i tried refering to the tutorial and had no luck

XAML

<?xml version="1.0" encoding="utf-8" ?>

<ContentPage.Content>









</ContentPage.Content>

C#

namespace oRec
{
public partial class Search : ContentPage
{
public Search()
{
InitializeComponent();

        var searchButton = this.FindByName<Button>("btnSearchOrder");
        searchButton.Clicked += async (sender, args) =>
        {
            this.activityIndicator1.IsRunning = true;

            string entryOrderNumber = entSearch.Text;
            var searchResults = await DependencyService.Get<ISearchRequestService>().SearchRequest(entryOrderNumber);
            //await DisplayAlert("Results", searchResults, "Done");

            RootObject purchaseOrder = JsonConvert.DeserializeObject<RootObject>(searchResults);
            int totalRecords = purchaseOrder.fs_P4312_W4312F.data.gridData.summary.records;

            List<string> purchaseOrderList = new List<string>();
            for(int i = 0; i<totalRecords; i++)
            {
                string orderDescription = purchaseOrder.fs_P4312_W4312F.data.gridData.rowset[i].sDescription_25.internalValue.ToString();
        string itemNumber = purchaseOrder.fs_P4312_W4312F.data.gridData.rowset[i].sitemNumber_26.internalValue.ToString();

       string orderValue = orderDescription+","+itemNumber;

                purchaseOrderList.Add(orderValue);
                string[] purchaseOrders = purchaseOrderList.ToArray();

                listView1.ItemsSource= purchaseOrderList;

            }

            this.activityIndicator1.IsRunning = false;
        };
    }

Thanks


Viewing all articles
Browse latest Browse all 91519

Trending Articles