Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

google map

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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!
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

772 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