I try to plot data from gridview on map like this
- [WebMethod]
- public static string mapgriddata(string FID,string ObtID)
- {
- try
- {
- string result = "";
- FID = HttpContext.Current.Session["FID"].ToString();
- ObID = HttpContext.Current.Session["ObID"].ToString();
- Entities w = new Entities();
- List
gt = w.spgetdata_ffid(FFID).ToList(); - DataTable dt = new DataTable();
- dt.Columns.Add("NO", typeof(string));
- dt.Columns.Add("Longitude", typeof(float));
- dt.Columns.Add("Latitude", typeof(float));
- foreach (var t in gt)
- {
- dt.Rows.Add(t.No, t.Longitude, t.Latitude);
- }
- string No = HttpContext.Current.Session["No"].ToString();
- float Latitude = Convert.ToSingle(HttpContext.Current.Session["Latitude"]);
- float Longitude = Convert.ToSingle(HttpContext.Current.Session["Longitude"]);
- result = DataSetToJSON(dt);
- return result;
- }
- catch (Exception)
- {
- throw new Exception();
- }
- }
page load
- protected void Page_Load(object sender, EventArgs e)
- {
- mapgriddata(Convert.ToString(Session["FID"]),Convert.ToString(Session["ObID"]));
- }
- }
but this show error
Object reference not set to an instance of an object.
Midhun TpPosted Sep 19, 2016, 8:32 AM
scropio gurlPosted Sep 19, 2016, 8:18 AM
Midhun T Pcheck update actually i am getting 3 values by mistake i write 5 please edit your answer
Midhun TpPosted Sep 19, 2016, 8:14 AM
- dt.Rows.Add(t.RegNo,t.DateTimeTD,t.Status,t.Speed,t.Latitude,t.Longitude);
You are adding 5 values to a datatable which consists only 3 columns. You should get error there.scropio gurlPosted Sep 19, 2016, 8:06 AM
Midhun T Pbut i want get these values through database
Midhun TpPosted Sep 19, 2016, 8:00 AM
scropio gurlPosted Sep 19, 2016, 7:59 AM
Midhun TpPosted Sep 19, 2016, 7:36 AM
scropio gurlPosted Sep 19, 2016, 7:09 AM
Midhun TpPosted Sep 19, 2016, 6:46 AM
to
scropio gurlPosted Sep 19, 2016, 6:21 AM
Midhun TpPosted Sep 19, 2016, 6:11 AM
scropio gurlPosted Sep 19, 2016, 5:44 AM
Midhun T P
scropio gurlPosted Sep 19, 2016, 5:31 AM
Midhun T P
Midhun TpPosted Sep 19, 2016, 5:26 AM