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 TpRank #388 · 6.5K reputationPosted Sep 19, 2016, 1:26 AM EDT
scropio gurl145 reputationPosted Sep 19, 2016, 1:31 AM EDT
Midhun T P
scropio gurl145 reputationPosted Sep 19, 2016, 1:44 AM EDT
Midhun T P
Midhun TpRank #388 · 6.5K reputationPosted Sep 19, 2016, 2:11 AM EDT
scropio gurl145 reputationPosted Sep 19, 2016, 2:21 AM EDT
Midhun TpRank #388 · 6.5K reputationPosted Sep 19, 2016, 2:46 AM EDT
to
scropio gurl145 reputationPosted Sep 19, 2016, 3:09 AM EDT
Midhun TpRank #388 · 6.5K reputationPosted Sep 19, 2016, 3:36 AM EDT
scropio gurl145 reputationPosted Sep 19, 2016, 3:59 AM EDT
Midhun TpRank #388 · 6.5K reputationPosted Sep 19, 2016, 4:00 AM EDT
scropio gurl145 reputationPosted Sep 19, 2016, 4:06 AM EDT
Midhun T Pbut i want get these values through database
Midhun TpRank #388 · 6.5K reputationPosted Sep 19, 2016, 4:14 AM EDT
- 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 gurl145 reputationPosted Sep 19, 2016, 4:18 AM EDT
Midhun T Pcheck update actually i am getting 3 values by mistake i write 5 please edit your answer
Midhun TpRank #388 · 6.5K reputationPosted Sep 19, 2016, 4:32 AM EDT