Hi ivinraj25,
I have created sample that full fill your requirement. You need to change this with your code.
HTML
CS.aspx
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Title" HeaderText="Title" />
<asp:BoundField DataField="Description" HeaderText="Description" />
<asp:BoundField DataField="Longitude" HeaderText="Longitude" />
<asp:BoundField DataField="Latitude" HeaderText="Latitude" />
<asp:BoundField DataField="Type" HeaderText="Type" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkMap" Text="Show Map" runat="server" OnClick="ShowMap" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
ShowMap.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Show Page</title>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false&key=AIzaSyAV8AiebjdcoS-Ratewz-HDkFt7XCq3zOM"></script>
<script type="text/javascript">
var markers = [
<asp:Repeater ID="rptMarkers" runat="server">
<ItemTemplate>
{
"title": '<%# Eval("Title") %>',
"lat": '<%# Eval("Latitude") %>',
"lng": '<%# Eval("Longitude") %>',
"description": '<%# Eval("Description") %>',
"type": '<%# Eval("Type") %>'
}
</ItemTemplate>
<SeparatorTemplate>
,
</SeparatorTemplate>
</asp:Repeater>
];
</script>
<script type="text/javascript">
window.onload = function () { LoadMap(); }
function LoadMap() {
var mapOptions = { center: new google.maps.LatLng(markers[0].lat, markers[0].lng), zoom: 15, mapTypeId: google.maps.MapTypeId.ROADMAP };
var infoWindow = new google.maps.InfoWindow();
var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
for (i = 0; i < markers.length; i++) {
var data = markers[i]
var myLatlng = new google.maps.LatLng(data.lat, data.lng);
var marker = new google.maps.Marker({ position: myLatlng, map: map, title: data.title });
(function (marker, data) {
google.maps.event.addListener(marker, "click", function (e) { infoWindow.setContent(data.description); infoWindow.open(map, marker); });
})(marker, data);
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="dvMap" style="width: 500px; height: 500px">
</div>
</form>
</body>
</html>
Code
CS.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
// Get DataTable From DataBase.
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] {
new DataColumn("Title"), new DataColumn("Latitude"), new DataColumn("Longitude"), new DataColumn("Description"), new DataColumn("Type") });
dt.Rows.Add("IVIN", "8.088306", "77.538451", "Basically am a Heart Specialist Doctor", "D");
dt.Rows.Add("Ratheesh", "18.520430", "73.856744", "Basically am a Neuro Surgeon Doctor", "P");
dt.Rows.Add("John Doe", "28.704059", "77.102490", "Basically am a Neuro Surgeon Doctor", "H");
dt.Rows.Add("Doe", "9.925201", "78.119775", "Basically am a Neuro Surgeon Doctor", "C");
dt.Rows.Add("Anto", "31.147130", "75.341218", "Basically am a Heart Specialist Doctor", "D");
dt.Rows.Add("Bibin", "10.850516", "76.271083", "Basically am a Heart Specialist Doctor", "P");
dt.Rows.Add("DR (COLONEL)CHITALKAR PRAKASH", "18.515729", "73.834868", "Null", "D");
dt.Rows.Add("DR (MRS) BARVE GOURI R", "18.516840", "73.834890", "Null", "D");
dt.Rows.Add("DR (MRS) BARVE GOURI R", "18.532630", "73.830130", "Null", "D");
dt.Rows.Add("DR ACHARI GOPAL", "18.618730", "73.753670", "Null", "D");
dt.Rows.Add("DR ADKAR NEERAJ", "18.529248", "73.843384", "Null", "D");
dt.Rows.Add("DR ADKAR NEERAJ", "18.480763", "73.872430", "Null", "D");
dt.Rows.Add("DR ADKAR NEERAJ", "18.554173", "73.819616", "Null", "D");
dt.Rows.Add("DR ADKAR RAJEEV", "18.509172", "73.831607", "Null", "D");
dt.Rows.Add("DR ADVANI D G", "18.541524", "73.889383", "Null", "D");
dt.Rows.Add("DR.A.CHARLES", "9.918078", "78.125464", "", "D");
dt.Rows.Add("DR (COLONEL)CHITALKAR PRAKASH", "18.477510", "73.889728", "", "D");
dt.Rows.Add("DR (MRS) BARVE GOURI R", "18.510714", "73.835288", "", "D");
dt.Rows.Add("DR (MRS) RUJUTA M PANSE", "18.554336", "73.801541", "", "D");
dt.Rows.Add("DR (MRS) PRABHUNE MANJUSHA", "18.510347", "73.815587", "", "D");
dt.Rows.Add("DR ABHYANKAR NITIN", "18.512419", "73.853139", "", "D");
dt.Rows.Add("DR ADATE SHALINI N", "18.460939", "73.812650", "", "D");
dt.Rows.Add("DR ADHICARY (MRS) SAUMYA", "18.555575", "73.808959", "", "D");
dt.Rows.Add("DR ADKAR (MRS) AADITEE R", "18.510714", "73.835288", "", "D");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
protected void ShowMap(object sender, EventArgs e)
{
GridViewRow row = (sender as LinkButton).NamingContainer as GridViewRow;
string title = row.Cells[(int)MAP.Title].Text;
string latitude = row.Cells[(int)MAP.Latitude].Text;
string longitude = row.Cells[(int)MAP.Longitude].Text;
string description = row.Cells[(int)MAP.Description].Text;
string type = row.Cells[(int)MAP.Type].Text;
Server.Transfer("ShowMap.aspx?lat=" + latitude + "&lng=" + longitude);
}
// Declare the enum to assign Enum value for easy access in grid index value
public enum MAP { Title = 0, Latitude = 3, Longitude = 2, Description = 1, Type = 4 }
ShowMap.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
if (Request.QueryString["lat"] != null && Request.QueryString["lng"] != null)
{
// Get DataTable From DataBase.
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] {
new DataColumn("Title"), new DataColumn("Latitude"), new DataColumn("Longitude"), new DataColumn("Description"), new DataColumn("Type") });
dt.Rows.Add("IVIN", "8.088306", "77.538451", "Basically am a Heart Specialist Doctor", "D");
dt.Rows.Add("Ratheesh", "18.520430", "73.856744", "Basically am a Neuro Surgeon Doctor", "P");
dt.Rows.Add("John Doe", "28.704059", "77.102490", "Basically am a Neuro Surgeon Doctor", "H");
dt.Rows.Add("Doe", "9.925201", "78.119775", "Basically am a Neuro Surgeon Doctor", "C");
dt.Rows.Add("Anto", "31.147130", "75.341218", "Basically am a Heart Specialist Doctor", "D");
dt.Rows.Add("Bibin", "10.850516", "76.271083", "Basically am a Heart Specialist Doctor", "P");
dt.Rows.Add("DR (COLONEL)CHITALKAR PRAKASH", "18.515729", "73.834868", "Null", "D");
dt.Rows.Add("DR (MRS) BARVE GOURI R", "18.516840", "73.834890", "Null", "D");
dt.Rows.Add("DR (MRS) BARVE GOURI R", "18.532630", "73.830130", "Null", "D");
dt.Rows.Add("DR ACHARI GOPAL", "18.618730", "73.753670", "Null", "D");
dt.Rows.Add("DR ADKAR NEERAJ", "18.529248", "73.843384", "Null", "D");
dt.Rows.Add("DR ADKAR NEERAJ", "18.480763", "73.872430", "Null", "D");
dt.Rows.Add("DR ADKAR NEERAJ", "18.554173", "73.819616", "Null", "D");
dt.Rows.Add("DR ADKAR RAJEEV", "18.509172", "73.831607", "Null", "D");
dt.Rows.Add("DR ADVANI D G", "18.541524", "73.889383", "Null", "D");
dt.Rows.Add("DR.A.CHARLES", "9.918078", "78.125464", "", "D");
dt.Rows.Add("DR (COLONEL)CHITALKAR PRAKASH", "18.477510", "73.889728", "", "D");
dt.Rows.Add("DR (MRS) BARVE GOURI R", "18.510714", "73.835288", "", "D");
dt.Rows.Add("DR (MRS) RUJUTA M PANSE", "18.554336", "73.801541", "", "D");
dt.Rows.Add("DR (MRS) PRABHUNE MANJUSHA", "18.510347", "73.815587", "", "D");
dt.Rows.Add("DR ABHYANKAR NITIN", "18.512419", "73.853139", "", "D");
dt.Rows.Add("DR ADATE SHALINI N", "18.460939", "73.812650", "", "D");
dt.Rows.Add("DR ADHICARY (MRS) SAUMYA", "18.555575", "73.808959", "", "D");
dt.Rows.Add("DR ADKAR (MRS) AADITEE R", "18.510714", "73.835288", "", "D");
DataRow[] dataRows = dt.Select("Latitude='" + Request.QueryString["lat"].ToString() + "' AND Longitude='" + Request.QueryString["lng"].ToString() + "'");
DataTable dtSelected = dt.Clone();
foreach (DataRow dataRow in dataRows)
{
dtSelected.Rows.Add(dataRow.ItemArray);
}
rptMarkers.DataSource = dtSelected;
rptMarkers.DataBind();
}
}
}
VB.aspx.vb
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
' Get DataTable From DataBase.
Dim dt As New DataTable()
dt.Columns.AddRange(New DataColumn() {New DataColumn("Title"), New DataColumn("Latitude"), New DataColumn("Longitude"), New DataColumn("Description"), New DataColumn("Type")})
dt.Rows.Add("IVIN", "8.088306", "77.538451", "Basically am a Heart Specialist Doctor", "D")
dt.Rows.Add("Ratheesh", "18.520430", "73.856744", "Basically am a Neuro Surgeon Doctor", "P")
dt.Rows.Add("John Doe", "28.704059", "77.102490", "Basically am a Neuro Surgeon Doctor", "H")
dt.Rows.Add("Doe", "9.925201", "78.119775", "Basically am a Neuro Surgeon Doctor", "C")
dt.Rows.Add("Anto", "31.147130", "75.341218", "Basically am a Heart Specialist Doctor", "D")
dt.Rows.Add("Bibin", "10.850516", "76.271083", "Basically am a Heart Specialist Doctor", "P")
dt.Rows.Add("DR (COLONEL)CHITALKAR PRAKASH", "18.515729", "73.834868", "Null", "D")
dt.Rows.Add("DR (MRS) BARVE GOURI R", "18.516840", "73.834890", "Null", "D")
dt.Rows.Add("DR (MRS) BARVE GOURI R", "18.532630", "73.830130", "Null", "D")
dt.Rows.Add("DR ACHARI GOPAL", "18.618730", "73.753670", "Null", "D")
dt.Rows.Add("DR ADKAR NEERAJ", "18.529248", "73.843384", "Null", "D")
dt.Rows.Add("DR ADKAR NEERAJ", "18.480763", "73.872430", "Null", "D")
dt.Rows.Add("DR ADKAR NEERAJ", "18.554173", "73.819616", "Null", "D")
dt.Rows.Add("DR ADKAR RAJEEV", "18.509172", "73.831607", "Null", "D")
dt.Rows.Add("DR ADVANI D G", "18.541524", "73.889383", "Null", "D")
dt.Rows.Add("DR.A.CHARLES", "9.918078", "78.125464", "", "D")
dt.Rows.Add("DR (COLONEL)CHITALKAR PRAKASH", "18.477510", "73.889728", "", "D")
dt.Rows.Add("DR (MRS) BARVE GOURI R", "18.510714", "73.835288", "", "D")
dt.Rows.Add("DR (MRS) RUJUTA M PANSE", "18.554336", "73.801541", "", "D")
dt.Rows.Add("DR (MRS) PRABHUNE MANJUSHA", "18.510347", "73.815587", "", "D")
dt.Rows.Add("DR ABHYANKAR NITIN", "18.512419", "73.853139", "", "D")
dt.Rows.Add("DR ADATE SHALINI N", "18.460939", "73.812650", "", "D")
dt.Rows.Add("DR ADHICARY (MRS) SAUMYA", "18.555575", "73.808959", "", "D")
dt.Rows.Add("DR ADKAR (MRS) AADITEE R", "18.510714", "73.835288", "", "D")
GridView1.DataSource = dt
GridView1.DataBind()
End If
End Sub
Protected Sub ShowMap(sender As Object, e As EventArgs)
Dim row As GridViewRow = TryCast(TryCast(sender, LinkButton).NamingContainer, GridViewRow)
Dim title As String = row.Cells(CInt(MAP.Title)).Text
Dim latitude As String = row.Cells(CInt(MAP.Latitude)).Text
Dim longitude As String = row.Cells(CInt(MAP.Longitude)).Text
Dim description As String = row.Cells(CInt(MAP.Description)).Text
Dim type As String = row.Cells(CInt(MAP.Type)).Text
Server.Transfer(Convert.ToString((Convert.ToString("ShowMapVB.aspx?lat=") & latitude) + "&lng=") & longitude)
End Sub
' Declare the enum to assign Enum value for easy access in grid index value
Public Enum MAP
Title = 0
Latitude = 3
Longitude = 2
Description = 1
Type = 4
End Enum
ShowMapVB.aspx.vb
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
If Request.QueryString("lat") IsNot Nothing AndAlso Request.QueryString("lng") IsNot Nothing Then
' Get DataTable From DataBase.
Dim dt As New DataTable()
dt.Columns.AddRange(New DataColumn() {New DataColumn("Title"), New DataColumn("Latitude"), New DataColumn("Longitude"), New DataColumn("Description"), New DataColumn("Type")})
dt.Rows.Add("IVIN", "8.088306", "77.538451", "Basically am a Heart Specialist Doctor", "D")
dt.Rows.Add("Ratheesh", "18.520430", "73.856744", "Basically am a Neuro Surgeon Doctor", "P")
dt.Rows.Add("John Doe", "28.704059", "77.102490", "Basically am a Neuro Surgeon Doctor", "H")
dt.Rows.Add("Doe", "9.925201", "78.119775", "Basically am a Neuro Surgeon Doctor", "C")
dt.Rows.Add("Anto", "31.147130", "75.341218", "Basically am a Heart Specialist Doctor", "D")
dt.Rows.Add("Bibin", "10.850516", "76.271083", "Basically am a Heart Specialist Doctor", "P")
dt.Rows.Add("DR (COLONEL)CHITALKAR PRAKASH", "18.515729", "73.834868", "Null", "D")
dt.Rows.Add("DR (MRS) BARVE GOURI R", "18.516840", "73.834890", "Null", "D")
dt.Rows.Add("DR (MRS) BARVE GOURI R", "18.532630", "73.830130", "Null", "D")
dt.Rows.Add("DR ACHARI GOPAL", "18.618730", "73.753670", "Null", "D")
dt.Rows.Add("DR ADKAR NEERAJ", "18.529248", "73.843384", "Null", "D")
dt.Rows.Add("DR ADKAR NEERAJ", "18.480763", "73.872430", "Null", "D")
dt.Rows.Add("DR ADKAR NEERAJ", "18.554173", "73.819616", "Null", "D")
dt.Rows.Add("DR ADKAR RAJEEV", "18.509172", "73.831607", "Null", "D")
dt.Rows.Add("DR ADVANI D G", "18.541524", "73.889383", "Null", "D")
dt.Rows.Add("DR.A.CHARLES", "9.918078", "78.125464", "", "D")
dt.Rows.Add("DR (COLONEL)CHITALKAR PRAKASH", "18.477510", "73.889728", "", "D")
dt.Rows.Add("DR (MRS) BARVE GOURI R", "18.510714", "73.835288", "", "D")
dt.Rows.Add("DR (MRS) RUJUTA M PANSE", "18.554336", "73.801541", "", "D")
dt.Rows.Add("DR (MRS) PRABHUNE MANJUSHA", "18.510347", "73.815587", "", "D")
dt.Rows.Add("DR ABHYANKAR NITIN", "18.512419", "73.853139", "", "D")
dt.Rows.Add("DR ADATE SHALINI N", "18.460939", "73.812650", "", "D")
dt.Rows.Add("DR ADHICARY (MRS) SAUMYA", "18.555575", "73.808959", "", "D")
dt.Rows.Add("DR ADKAR (MRS) AADITEE R", "18.510714", "73.835288", "", "D")
Dim dataRows As DataRow() = dt.[Select]("Latitude='" + Request.QueryString("lat").ToString() + "' AND Longitude='" + Request.QueryString("lng").ToString() + "'")
Dim dtSelected As DataTable = dt.Clone()
For Each dataRow As DataRow In dataRows
dtSelected.Rows.Add(dataRow.ItemArray)
Next
rptMarkers.DataSource = dtSelected
rptMarkers.DataBind()
End If
End If
End Sub
Screenshot
