[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

google map

Posted on 2011-09-06
3
Medium Priority
?
333 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 1000 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

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

640 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