Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

google map

Posted on 2011-09-06
3
316 Views
Last Modified: 2012-05-12
Hey guys i am using googlemaps.subgurim.net

my problem is that it keep flickering when i do a post back and if i assign a datasource to the map it works but when i put an empty datasource it does not change.

please help.

i will post my code:

 
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BusinessLayer;
using Subgurim.Controles;
using System.Xml;
using System.Collections.Generic;
using TextboxControl;
using System.Text;

public partial class _Default : System.Web.UI.Page
{
    areas ar = new areas();
    foodtypes ft = new foodtypes();
    sql s = new sql();
    PagedDataSource pds = new PagedDataSource();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) 
        {
            DataTable dt_ft = ft.return_foodtype();

            for (int i = 0; i < dt_ft.Rows.Count; i++)
            {
                ListItem lst = new ListItem(dt_ft.Rows[i][1].ToString(), dt_ft.Rows[i][1].ToString());
                CheckMenuFoodType.Items.Add(lst);
                CheckMenuFoodType.Items[i].Selected = true;
            }

            DataTable dt_areas = ar.return_areas();
            ddArea.Items.Add("List of Area's:");
            ddArea.DataSource = dt_areas;
            ddArea.DataTextField = "Group Name";
            ddArea.DataBind();

            BindGrid(CurrentSql);

            txtSearch.Attributes.Add("onkeydown", "javascript:if((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)){document.getElementById('" + btnSearch.ClientID + "').click();return false;}else return true;");
        }
    }

    public void mapLoad()
    {
        map.addGMapUI(new GMapUI());

        map.setCenter(new GLatLng(-25.739292, 28.161392), 8);
    }

    protected void ddArea_SelectedIndexChanged(object sender, EventArgs e)
    {
        String values = "";
        for (int i = 0; i < CheckMenuFoodType.Items.Count; i++)
        {
            if (CheckMenuFoodType.Items[i].Selected)
            {
                values += "'" + CheckMenuFoodType.Items[i].Text + "'" + ",";
            }
        }

        string Foodtypes = values.TrimEnd(',');

        if (ddArea.SelectedIndex > 0)
        {
            string area = ddArea.SelectedItem.Text;

            if (Foodtypes == "")
            {
                CurrentSql = "select DISTINCT UPPER(r_name) as r_name,  UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria where area ='" + area + "' and active='Yes'";
                BindGrid("select DISTINCT UPPER(r_name) as r_name, UPPER(address) as address, area, location, p_code, tel, website,  '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria where area ='" + area + "' and active='Yes'");
            }
            else
            {
                CurrentSql = "select DISTINCT UPPER(r_name) as r_name,  UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria p join foodtypes f on p.foodtypes like '%'+ f.type+'%' where f.type IN (" + Foodtypes + ") and area ='" + area + "' and active='Yes'";
                BindGrid("select DISTINCT UPPER(r_name) as r_name,  UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria p join foodtypes f on p.foodtypes like '%'+ f.type+'%' where f.type IN (" + Foodtypes + ") and area ='" + area + "' and active='Yes'");
            }
        }
        else
        {
            CurrentSql = "";
            BindGrid("");
        }
    }

    public string DisplayMarkerInfo(string address, string area, string location, string p_code)
    {
        string display = "";

        if (location == null) 
        {
            display =  address + "<br/>" + area + "<br/>" + p_code;
        }
        else 
        {
            display =  address + "<br/>" + area + "<br/>" + location + "<br/>" + p_code;
        }

        return display;
    }

    protected void map_Load(object sender, EventArgs e)
    {
        mapLoad();
    }


    private void BindGrid(string sql_query)
    {
        DataTable dt = new DataTable();
        s.Query = sql_query;
        dt = s.sql_query();
        DataView dv = dt.DefaultView;

        if (this.ViewState["SortExp"] != null)
        {
            dv.Sort = this.ViewState["SortExp"].ToString() + " " + this.ViewState["SortOrder"].ToString();
        }

        pds.DataSource = dv;
        pds.AllowPaging = true;
        pds.PageSize = 20;
        pds.CurrentPageIndex = CurrentPage;
        lnkbtnNext.Enabled = !pds.IsLastPage;
        lnkbtnPrevious.Enabled = !pds.IsFirstPage;

        if (dv.Count > 0)
        {
            GridView1.DataSource = pds;
            GridView1.DataBind();

            map.DataSource = pds;
            map.DataBind();

            lblresults.Text = dt.Rows.Count.ToString() + " Results Found:";
            Pager.Visible = true;
        }
        else
        {
            GridView1.DataSource = "";
            GridView1.DataBind();

            map.DataSource = "";
            map.DataBind();

            lblresults.Text = "0 Results Found:";
            Pager.Visible = false;
        }

        doPaging();
    }

    public int CurrentPage
    {
        get
        {
            if (this.ViewState["CurrentPage"] == null)
                return 0;
            else
                return Convert.ToInt16(this.ViewState["CurrentPage"].ToString());
        }
        set
        {
            this.ViewState["CurrentPage"] = value;
        }
    }

    public string CurrentSql
    {
        get
        {
            if (this.ViewState["CurrentSql"] == null)
            {
                return "select DISTINCT UPPER(r_name) as r_name, UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') +  '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng FROM dbo.pretoria where active='Yes'";
            }
            else
                return Convert.ToString(this.ViewState["CurrentSql"].ToString());
        }
        set
        {
            this.ViewState["CurrentSql"] = value;
        }
    }

    private void doPaging()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("PageIndex");
        dt.Columns.Add("PageText");
        for (int i = 0; i < pds.PageCount; i++)
        {
            DataRow dr = dt.NewRow();
            dr[0] = i;
            dr[1] = i + 1;
            dt.Rows.Add(dr);
        }

        dlPaging.DataSource = dt;
        dlPaging.DataBind();
    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("Sort"))
        {
            if (this.ViewState["SortExp"] == null)
            {
                this.ViewState["SortExp"] = e.CommandArgument.ToString();
                this.ViewState["SortOrder"] = "ASC";
            }
            else
            {
                if (this.ViewState["SortExp"].ToString() == e.CommandArgument.ToString())
                {
                    if (this.ViewState["SortOrder"].ToString() == "ASC")
                        this.ViewState["SortOrder"] = "DESC";
                    else
                        this.ViewState["SortOrder"] = "ASC";
                }
                else
                {
                    this.ViewState["SortOrder"] = "ASC";
                    this.ViewState["SortExp"] = e.CommandArgument.ToString();
                }
            }
            BindGrid(CurrentSql);
        }
    }

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header && this.ViewState["SortExp"] != null)
        {
            Image ImgSort = new Image();
            if (this.ViewState["SortOrder"].ToString() == "ASC")
            {
                ImgSort.Width = Unit.Parse("11px");
                ImgSort.Height = Unit.Parse("8px");
                ImgSort.ImageUrl = "~/images/Master/down.gif";
            }

            else
            {
                ImgSort.Width = Unit.Parse("11px");
                ImgSort.Height = Unit.Parse("8px");
                ImgSort.ImageUrl = "~/images/Master/up.gif";
            }

            switch (this.ViewState["SortExp"].ToString())
            {
                case "r_name":
                    PlaceHolder placeholderName = (PlaceHolder)e.Row.FindControl("placeholderName");
                    placeholderName.Controls.Add(ImgSort);
                    break;

                case "address":
                    PlaceHolder placeholderAddress = (PlaceHolder)e.Row.FindControl("placeholderAddress");
                    placeholderAddress.Controls.Add(ImgSort);
                    break;

                case "tel":
                    PlaceHolder placeholderTel_no = (PlaceHolder)e.Row.FindControl("placeholderTel_no");
                    placeholderTel_no.Controls.Add(ImgSort);
                    break;

                case "website":
                    PlaceHolder placeholderWebsite = (PlaceHolder)e.Row.FindControl("placeholderWebsite");
                    placeholderWebsite.Controls.Add(ImgSort);
                    break;
            }
        }
    }

    protected void dlPaging_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName.Equals("lnkbtnPaging"))
        {
            CurrentPage = Convert.ToInt16(e.CommandArgument.ToString());
            BindGrid(CurrentSql);
        }
    }

    protected void dlPaging_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        LinkButton lnkbtnPage = (LinkButton)e.Item.FindControl("lnkbtnPaging");
    }

    protected void lnkbtnPrevious_Click(object sender, EventArgs e)
    {
        CurrentPage -= 1;
        BindGrid(CurrentSql);
    }

    protected void lnkbtnNext_Click(object sender, EventArgs e)
    {
        CurrentPage += 1;
        BindGrid(CurrentSql);
    }

    protected void CheckMenuFoodType_SelectedIndexChanged(object sender, EventArgs e)
    {
        String values = "";
        for (int i = 0; i < CheckMenuFoodType.Items.Count; i++)
        {
            if (CheckMenuFoodType.Items[i].Selected)
            {
                values += "'" + CheckMenuFoodType.Items[i].Text + "'" + ",";
            }
        }

        string Foodtypes = values.TrimEnd(',');

        if (ddArea.SelectedIndex > 0)
        {
            string area = ddArea.SelectedItem.Text;

            if (Foodtypes == "")
            {
                CurrentSql = "select DISTINCT UPPER(r_name) as r_name,  UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria where area ='" + area + "' and active='Yes'";
                BindGrid("select DISTINCT UPPER(r_name) as r_name,  UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria where area ='" + area + "' and active='Yes'");
            }
            else
            {
                CurrentSql = "select DISTINCT UPPER(r_name) as r_name,  UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria p join foodtypes f on p.foodtypes like '%'+ f.type+'%' where f.type IN (" + Foodtypes + ") and area ='" + area + "' and active='Yes'";
                BindGrid("select DISTINCT UPPER(r_name) as r_name,  UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria p join foodtypes f on p.foodtypes like '%'+ f.type+'%' where f.type IN (" + Foodtypes + ") and area ='" + area + "' and active='Yes'");
            }
        }
        else
        {
            if (Foodtypes == "")
            {
                CurrentSql = "";
                BindGrid("");
            }
            else
            {
                CurrentSql = "select DISTINCT UPPER(r_name) as r_name, UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria p join foodtypes f on p.foodtypes like '%'+ f.type+'%' where f.type IN (" + Foodtypes + ") and active='Yes'";
                BindGrid("select DISTINCT UPPER(r_name) as r_name,  UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria p join foodtypes f on p.foodtypes like '%'+ f.type+'%' where f.type IN (" + Foodtypes + ") and active='Yes'");
            }
        }
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        CurrentSql = "select DISTINCT UPPER(r_name) as r_name,  UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria where (lower(r_name)) like lower('%" + txtSearch.Text + "%') and active='Yes'";
        BindGrid("select DISTINCT UPPER(r_name) as r_name, UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria where (lower(r_name)) like lower('%" + txtSearch.Text + "%') and active='Yes'");
    }

    protected void imghttp_Command(object sender, CommandEventArgs e)
    {
        string url = "http://" + e.CommandArgument.ToString();

        StringBuilder sb = new StringBuilder();
        sb.Append("window.open('" + url + "','','left=300,top=400,resizable=0,scrollbars=1');");

        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", sb.ToString(), true);
    }
}

Open in new window


 
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BusinessLayer;
using Subgurim.Controles;
using System.Xml;
using System.Collections.Generic;
using TextboxControl;
using System.Text;

public partial class _Default : System.Web.UI.Page
{
    areas ar = new areas();
    foodtypes ft = new foodtypes();
    sql s = new sql();
    PagedDataSource pds = new PagedDataSource();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) 
        {
            DataTable dt_ft = ft.return_foodtype();

            for (int i = 0; i < dt_ft.Rows.Count; i++)
            {
                ListItem lst = new ListItem(dt_ft.Rows[i][1].ToString(), dt_ft.Rows[i][1].ToString());
                CheckMenuFoodType.Items.Add(lst);
                CheckMenuFoodType.Items[i].Selected = true;
            }

            DataTable dt_areas = ar.return_areas();
            ddArea.Items.Add("List of Area's:");
            ddArea.DataSource = dt_areas;
            ddArea.DataTextField = "Group Name";
            ddArea.DataBind();

            BindGrid(CurrentSql);

            txtSearch.Attributes.Add("onkeydown", "javascript:if((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)){document.getElementById('" + btnSearch.ClientID + "').click();return false;}else return true;");
        }
    }

    public void mapLoad()
    {
        map.addGMapUI(new GMapUI());

        map.setCenter(new GLatLng(-25.739292, 28.161392), 8);
    }

    protected void ddArea_SelectedIndexChanged(object sender, EventArgs e)
    {
        String values = "";
        for (int i = 0; i < CheckMenuFoodType.Items.Count; i++)
        {
            if (CheckMenuFoodType.Items[i].Selected)
            {
                values += "'" + CheckMenuFoodType.Items[i].Text + "'" + ",";
            }
        }

        string Foodtypes = values.TrimEnd(',');

        if (ddArea.SelectedIndex > 0)
        {
            string area = ddArea.SelectedItem.Text;

            if (Foodtypes == "")
            {
                CurrentSql = "select DISTINCT UPPER(r_name) as r_name,  UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria where area ='" + area + "' and active='Yes'";
                BindGrid("select DISTINCT UPPER(r_name) as r_name, UPPER(address) as address, area, location, p_code, tel, website,  '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria where area ='" + area + "' and active='Yes'");
            }
            else
            {
                CurrentSql = "select DISTINCT UPPER(r_name) as r_name,  UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria p join foodtypes f on p.foodtypes like '%'+ f.type+'%' where f.type IN (" + Foodtypes + ") and area ='" + area + "' and active='Yes'";
                BindGrid("select DISTINCT UPPER(r_name) as r_name,  UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria p join foodtypes f on p.foodtypes like '%'+ f.type+'%' where f.type IN (" + Foodtypes + ") and area ='" + area + "' and active='Yes'");
            }
        }
        else
        {
            CurrentSql = "";
            BindGrid("");
        }
    }

    public string DisplayMarkerInfo(string address, string area, string location, string p_code)
    {
        string display = "";

        if (location == null) 
        {
            display =  address + "<br/>" + area + "<br/>" + p_code;
        }
        else 
        {
            display =  address + "<br/>" + area + "<br/>" + location + "<br/>" + p_code;
        }

        return display;
    }

    protected void map_Load(object sender, EventArgs e)
    {
        mapLoad();
    }


    private void BindGrid(string sql_query)
    {
        DataTable dt = new DataTable();
        s.Query = sql_query;
        dt = s.sql_query();
        DataView dv = dt.DefaultView;

        if (this.ViewState["SortExp"] != null)
        {
            dv.Sort = this.ViewState["SortExp"].ToString() + " " + this.ViewState["SortOrder"].ToString();
        }

        pds.DataSource = dv;
        pds.AllowPaging = true;
        pds.PageSize = 20;
        pds.CurrentPageIndex = CurrentPage;
        lnkbtnNext.Enabled = !pds.IsLastPage;
        lnkbtnPrevious.Enabled = !pds.IsFirstPage;

        if (dv.Count > 0)
        {
            GridView1.DataSource = pds;
            GridView1.DataBind();

            map.DataSource = pds;
            map.DataBind();

            lblresults.Text = dt.Rows.Count.ToString() + " Results Found:";
            Pager.Visible = true;
        }
        else
        {
            GridView1.DataSource = "";
            GridView1.DataBind();

            map.DataSource = "";
            map.DataBind();

            lblresults.Text = "0 Results Found:";
            Pager.Visible = false;
        }

        doPaging();
    }

    public int CurrentPage
    {
        get
        {
            if (this.ViewState["CurrentPage"] == null)
                return 0;
            else
                return Convert.ToInt16(this.ViewState["CurrentPage"].ToString());
        }
        set
        {
            this.ViewState["CurrentPage"] = value;
        }
    }

    public string CurrentSql
    {
        get
        {
            if (this.ViewState["CurrentSql"] == null)
            {
                return "select DISTINCT UPPER(r_name) as r_name, UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') +  '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng FROM dbo.pretoria where active='Yes'";
            }
            else
                return Convert.ToString(this.ViewState["CurrentSql"].ToString());
        }
        set
        {
            this.ViewState["CurrentSql"] = value;
        }
    }

    private void doPaging()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("PageIndex");
        dt.Columns.Add("PageText");
        for (int i = 0; i < pds.PageCount; i++)
        {
            DataRow dr = dt.NewRow();
            dr[0] = i;
            dr[1] = i + 1;
            dt.Rows.Add(dr);
        }

        dlPaging.DataSource = dt;
        dlPaging.DataBind();
    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("Sort"))
        {
            if (this.ViewState["SortExp"] == null)
            {
                this.ViewState["SortExp"] = e.CommandArgument.ToString();
                this.ViewState["SortOrder"] = "ASC";
            }
            else
            {
                if (this.ViewState["SortExp"].ToString() == e.CommandArgument.ToString())
                {
                    if (this.ViewState["SortOrder"].ToString() == "ASC")
                        this.ViewState["SortOrder"] = "DESC";
                    else
                        this.ViewState["SortOrder"] = "ASC";
                }
                else
                {
                    this.ViewState["SortOrder"] = "ASC";
                    this.ViewState["SortExp"] = e.CommandArgument.ToString();
                }
            }
            BindGrid(CurrentSql);
        }
    }

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header && this.ViewState["SortExp"] != null)
        {
            Image ImgSort = new Image();
            if (this.ViewState["SortOrder"].ToString() == "ASC")
            {
                ImgSort.Width = Unit.Parse("11px");
                ImgSort.Height = Unit.Parse("8px");
                ImgSort.ImageUrl = "~/images/Master/down.gif";
            }

            else
            {
                ImgSort.Width = Unit.Parse("11px");
                ImgSort.Height = Unit.Parse("8px");
                ImgSort.ImageUrl = "~/images/Master/up.gif";
            }

            switch (this.ViewState["SortExp"].ToString())
            {
                case "r_name":
                    PlaceHolder placeholderName = (PlaceHolder)e.Row.FindControl("placeholderName");
                    placeholderName.Controls.Add(ImgSort);
                    break;

                case "address":
                    PlaceHolder placeholderAddress = (PlaceHolder)e.Row.FindControl("placeholderAddress");
                    placeholderAddress.Controls.Add(ImgSort);
                    break;

                case "tel":
                    PlaceHolder placeholderTel_no = (PlaceHolder)e.Row.FindControl("placeholderTel_no");
                    placeholderTel_no.Controls.Add(ImgSort);
                    break;

                case "website":
                    PlaceHolder placeholderWebsite = (PlaceHolder)e.Row.FindControl("placeholderWebsite");
                    placeholderWebsite.Controls.Add(ImgSort);
                    break;
            }
        }
    }

    protected void dlPaging_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName.Equals("lnkbtnPaging"))
        {
            CurrentPage = Convert.ToInt16(e.CommandArgument.ToString());
            BindGrid(CurrentSql);
        }
    }

    protected void dlPaging_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        LinkButton lnkbtnPage = (LinkButton)e.Item.FindControl("lnkbtnPaging");
    }

    protected void lnkbtnPrevious_Click(object sender, EventArgs e)
    {
        CurrentPage -= 1;
        BindGrid(CurrentSql);
    }

    protected void lnkbtnNext_Click(object sender, EventArgs e)
    {
        CurrentPage += 1;
        BindGrid(CurrentSql);
    }

    protected void CheckMenuFoodType_SelectedIndexChanged(object sender, EventArgs e)
    {
        String values = "";
        for (int i = 0; i < CheckMenuFoodType.Items.Count; i++)
        {
            if (CheckMenuFoodType.Items[i].Selected)
            {
                values += "'" + CheckMenuFoodType.Items[i].Text + "'" + ",";
            }
        }

        string Foodtypes = values.TrimEnd(',');

        if (ddArea.SelectedIndex > 0)
        {
            string area = ddArea.SelectedItem.Text;

            if (Foodtypes == "")
            {
                CurrentSql = "select DISTINCT UPPER(r_name) as r_name,  UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria where area ='" + area + "' and active='Yes'";
                BindGrid("select DISTINCT UPPER(r_name) as r_name,  UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria where area ='" + area + "' and active='Yes'");
            }
            else
            {
                CurrentSql = "select DISTINCT UPPER(r_name) as r_name,  UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria p join foodtypes f on p.foodtypes like '%'+ f.type+'%' where f.type IN (" + Foodtypes + ") and area ='" + area + "' and active='Yes'";
                BindGrid("select DISTINCT UPPER(r_name) as r_name,  UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria p join foodtypes f on p.foodtypes like '%'+ f.type+'%' where f.type IN (" + Foodtypes + ") and area ='" + area + "' and active='Yes'");
            }
        }
        else
        {
            if (Foodtypes == "")
            {
                CurrentSql = "";
                BindGrid("");
            }
            else
            {
                CurrentSql = "select DISTINCT UPPER(r_name) as r_name, UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria p join foodtypes f on p.foodtypes like '%'+ f.type+'%' where f.type IN (" + Foodtypes + ") and active='Yes'";
                BindGrid("select DISTINCT UPPER(r_name) as r_name,  UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria p join foodtypes f on p.foodtypes like '%'+ f.type+'%' where f.type IN (" + Foodtypes + ") and active='Yes'");
            }
        }
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        CurrentSql = "select DISTINCT UPPER(r_name) as r_name,  UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria where (lower(r_name)) like lower('%" + txtSearch.Text + "%') and active='Yes'";
        BindGrid("select DISTINCT UPPER(r_name) as r_name, UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ r_name + '</b>' + '<br>' + address + '<br>' + area + '<br>' + IsNull(location,'') + '<br> Contact: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng from pretoria where (lower(r_name)) like lower('%" + txtSearch.Text + "%') and active='Yes'");
    }

    protected void imghttp_Command(object sender, CommandEventArgs e)
    {
        string url = "http://" + e.CommandArgument.ToString();

        StringBuilder sb = new StringBuilder();
        sb.Append("window.open('" + url + "','','left=300,top=400,resizable=0,scrollbars=1');");

        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", sb.ToString(), true);
    }
}

Open in new window

<cc1:GMap ID="map" runat="server" DataGInfoWindowTextField="InfoWindowText" enableHookMouseWheelToZoom="True"
                                        Height="400px" OnLoad="map_Load" Width="560px" 
                                        ajaxUpdateProgressMessage="Please wait..." EnableViewState="False" />

Open in new window

0
Comment
Question by:JCWEBHOST
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 500 total points
ID: 36487999
Remove if (!IsPostBack) condition and try.
0
 

Author Comment

by:JCWEBHOST
ID: 36501494
nope still the same
0
 

Author Closing Comment

by:JCWEBHOST
ID: 36522650
thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Check number of row prior to displaying gridview 10 62
Writing comments on <p></P> or paragraph 2 19
Html form and modal / img src -problem 3 30
ASP.NET Content Page 3 29
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question