Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8478391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:43:57+00:00 2026-06-10T18:43:57+00:00

I am binding a DataList with dynamic values (ie distances from google api From

  • 0

I am binding a DataList with dynamic values (ie distances from google api From a particular location.)

ie from x location :

10 km away
15 km away etc as follows

enter image description here

Using this code in ItemDataBound :

private void bindDataList(string location)
{
  DataSet dstProperty = Tbl_PropertyMaster.getPropertiesByLocation(location);
  dlstNearbyProperties.DataSource = dstProperty;
  dlstNearbyProperties.DataBind();
}

.

protected void dlstNearbyProperties_ItemDataBound(object sender, DataListItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Item ||
         e.Item.ItemType == ListItemType.AlternatingItem)
    {
        Label lblPropId = (Label)e.Item.FindControl("lblPropId");
        Label lblKmAway = (Label)e.Item.FindControl("lblKmAway");
        Label lblPrice = (Label)e.Item.FindControl("lblPrice");
        DataSet dstEnabledStat = Tbl_PropertyMaster.GetPropertyDetailsbyId(Convert.ToInt32(lblPropId.Text));
        if (dstEnabledStat.Tables[0].Rows.Count > 0)
        {
            //string origin = "8.5572357 ,76.87649310000006";
            string origin = InitialOrigin;
            string destination = dstEnabledStat.Tables[0].Rows[0]["Latitude"].ToString() + "," + dstEnabledStat.Tables[0].Rows[0]["Longitude"].ToString();
            lblKmAway.Text = devTools.getDistance(origin, destination) + " Away";
        }
        lblPrice.Text = getMinnimumOfRoomPrice(Convert.ToInt32(lblPropId.Text));
   }
}

Is there a way to sort these value in ascendind or descening w.r.t distances .

NB: Distances are not DB values,they are dynamic.

Can this be sorted in a Button1_Click ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:43:59+00:00Added an answer on June 10, 2026 at 6:43 pm

    Alrite after lot of hours of playing with codes I did it.

    The following is for GRIDVIEW,Similar steps can be followed for DataList As well.

    Page Load : I added an extra column ‘Miles’ to the already existing datatable

    protected void Page_Load(object sender, EventArgs e)
    {
        dtbl = Tbl_PropertyMaster.SelectAllPropertyAndUserDetails().Tables[0];
        dtbl.Columns.Add("Miles", typeof(int));
        //userId = devTools.checkAdminLoginStatus();
        if (!IsPostBack)
        {
            fillDlPhotoViewAll();
            FillGrProperty();
    
        }
    }
    

    Row Data Bound :

    protected void grProperty_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
    
        DataSet dstEnabledStat = Tbl_PropertyMaster.GetPropertyDetailsbyId(PropId);
        if (dstEnabledStat.Tables[0].Rows.Count > 0)
        {
            string origin = InitialOrigin;
                string destination = dstEnabledStat.Tables[0].Rows[0]["Latitude"].ToString() + "," + dstEnabledStat.Tables[0].Rows[0]["Longitude"].ToString();
                decimal Kilometre=0.00M;
                if(devTools.getDistance(origin, destination)!=0)
                {
                Kilometre=Convert.ToDecimal(devTools.getDistance(origin, destination))/1000;
                }
                lblmiles.Text = Kilometre.ToString() + "Kms";
                dtbl.Rows[inn]["Miles"] = Convert.ToInt32(devTools.getDistance(origin, destination));
                inn = inn + 1;
        }
    }
    ViewState["dtbl"] = dtbl;
    }
    

    Sort by distance Button_Click:

    protected void btnSort_Click(object sender, EventArgs e)
    {
        DataTable dataTable;
        dataTable = (DataTable)ViewState["dtbl"];
        if (dataTable.Rows.Count > 0)
        {
            dataTable.DefaultView.Sort = "Miles DESC";
            dataTable.AcceptChanges();
            grProperty.DataSource = dataTable;
            grProperty.DataBind();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have asp:datalist binding from table this table contain two columns one of them
I am using this code for datalist validation. I am binding the image in
When binding values to controls I have plenty of this: Text='<%# Bind(StartDate, {0:dd.MM.yyyy}) %>'
I am populating a DataTable using ADO.NET and binding a DataList and it works.
When binding code to the execution of an event using mxml, by assigning the
in my web application i have a datalist in that i am binding some
The code below works perfect for binding actual urls grabbed from the net. My
Using MVVM and EF...I have a datagrid binding to a View Model (using ObservableCollection).
I am trying to do data binding in WPF on a data grid using
Binding model to the view. my model Person has {Id,Title,Address...etc) In my controller I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.