0

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.

Edited by mike_2000_17: Fixed formatting

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by nat06
0

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.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.