I am new to asp.net and C# web application development.
My question is: I have a GridView1
which is bound to a data source which is getting data from a SQL Server table.
Gridview1
has these columns:
- select(default select available in gridview to select row)
- time
- customer
- address
- longitude (visible = false)
- latitude (visible = false)
This data is also filtered and sorted by a drop down list date
What I want to do is when my page load the value of latitude and longitude column first row value get assigned to my variable lat and lng
This is what I am writing, basically the lat and lng variable will be used in my another function:
Double lat, lng;
lat = Convert.ToDouble(GridView1.Rows[1].Cells[4].Text);
lng = Convert.ToDouble(GridView1.Rows[1].Cells[5].Text);
GLatLng latlong = new GLatLng(lat, lng);
GMap1.setCenter(latlong, 10);
The following exception is thrown:
Index was out of range. Must be non-negative and less than the size of the collection.
The gridview data is never null it always has some data