Example #1
0
    protected void BindSite()
    {
        //change done by meenakshi
        int hubid = 0;

        if (drpHub.SelectedValue != "")
        {
            hubid = Convert.ToInt32(drpHub.SelectedValue);
        }


        if (hubid != 0)
        {
            colSite = objSite.Get_By_hubid_site(hubid);

            drpsite.DataTextField  = "sitename";
            drpsite.DataValueField = "siteid";
            //drpsite.DataSource = colSite;
            drpsite.DataSource = colSite;
            drpsite.DataBind();
            ListItem item = new ListItem();
            //item.Selected = true;
            item.Text  = "All";
            item.Value = "0";
            drpsite.Items.Add(item);
            drpsite.SelectedValue = "0";
        }
        else
        {
            colSite = objSite.Get_All();
            //colSite = objSite.Get_By_hubid_site(hubid);
            for (int i = 0; i < colSite.Count; i++)
            {
                for (int j = i; j < colSite.Count; j++)
                {
                    if (String.Compare(colSite[i].Sitename, colSite[j].Sitename) > 0)
                    {
                        Site_mst obj = new Site_mst();
                        obj        = colSite[i];
                        colSite[i] = colSite[j];
                        colSite[j] = obj;
                    }
                }
            }

            drpsite.DataTextField  = "sitename";
            drpsite.DataValueField = "siteid";
            //drpsite.DataSource = colSite;
            drpsite.DataSource = colSite;
            drpsite.DataBind();
            ListItem item = new ListItem();
            //item.Selected = true;
            item.Text  = "All";
            item.Value = "0";
            drpsite.Items.Add(item);
            drpsite.SelectedValue = "0";
        }
    }