private void populateDropDown(DropDownList ddl, string groupName)
        {
            DataTable dt = Utils.GetCodeValue(groupName, "");

            if (dt.Rows.Count > 0)
            {
                ddl.DataValueField = "Value";
                ddl.DataTextField  = "Value";
                ddl.DataSource     = dt;
                ddl.DataBind();
            }
        }
Exemple #2
0
        private void bindData(bool viewOnly)
        {
            dtUseCategory = Utils.GetCodeValue("WEB_FAVORITE_USAGE", "");

            DataTable dt = null;

            using (var sd = UserManager.GetSecureData(true))
            {
                int wuserid = sd.WebUserID;
                dt = sd.GetData("web_favorites_view", ":wuserid=" + wuserid + ";:accessionid=" + 0, 0, 0).Tables["web_favorites_view"];
            }

            // using tree view
            //tvFavorite.Nodes.Clear();
            //foreach (DataRow dr in dt.Rows)
            //{
            //    var child = new TreeNode(dr["pi_number"].ToString(), dr["accession_id"].ToString());
            //        tvFavorite.Nodes.Add(child);
            //}


            if (dt != null)
            {
                int cnt = dt.Rows.Count;
                if (cnt > 0)
                {
                    lblCnt.Text = " (" + cnt.ToString() + (cnt == 1? " item)": " items)");
                }
            }

            // using gridview
            if (viewOnly)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if (dr["Note"].ToString().Contains("\r\n"))
                    {
                        dr["Note"] = dr["Note"].ToString().Replace("\r\n", "<br />");
                    }
                }
            }

            gvFavorite.DataSource = dt;
            gvFavorite.DataBind();

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