Hi,

I have a GridView and want to create an array of type struct of the GridView's float type elements.

Here is part of the code:

public struct Point
    {
        public float lat;
        public float lon;
    }
.....



public Point[] GetPoint()
    {
        int br = GridView1.Rows.Count;
        Point[] Niza = new Point[br];

        foreach (GridViewRow row in GridView1.Rows)
        {
            int i = 0;

            [B]Niza[i].lat = float.Parse(row.Cells[3].Text, System.Globalization.NumberStyles.Any);
            Niza[i].lon = float.Parse(row.Cells[4].Text, System.Globalization.NumberStyles.Any);[/B]            i++;

        }
        return Niza;
    }

This is not OK. I debuged the code and I got right values on the right side, but elements in the array got values 0.0, so left side of the equation is 0.0.

Can anybody help me please?
Thank you in advance.

Recommended Answers

All 2 Replies

Make sure your accessing the data in the correct column, gridviews will often contain extra, empty and unused columns that don't get rendered on the browser.

Make sure your accessing the data in the correct column, gridviews will often contain extra, empty and unused columns that don't get rendered on the browser.

I am sure the columns are correct because on the right side of the equation

float.Parse(row.Cells[3].Text, System.Globalization.NumberStyles.Any)

is correct, but the result on the left side
Niza.lat=
is not ok, it is 0.0 when I debug.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.