Exemple #1
0
 public void LoadAuthors()
 {
     lstAddAuthors.DataSource     = SSPUser.getAllAuthors();
     lstAddAuthors.DataTextField  = "Name";
     lstAddAuthors.DataValueField = "CKey";
     lstAddAuthors.DataBind();
     lstAddAuthors.Items.Insert(0, new ListItem("Please select"));
 }
Exemple #2
0
        public List <SSPUser> GetAllAuthors()  //for dropdown
        {
            try
            {
                return(SSPUser.getAllAuthors());
            }
            catch (Exception ex)
            {
                var resp = new HttpResponseMessage(HttpStatusCode.ExpectationFailed)

                {
                    ReasonPhrase = ex.Message
                };

                throw new HttpResponseException(resp);
            }
        }
Exemple #3
0
        protected void grdAuthors_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                ////Find the DropDownList in the Row
                //DropDownList lstAuthors = (e.Row.FindControl("lstAuthors") as DropDownList);

                //lstAuthors.DataSource = SSPUser.getAll(); //new Author().getAuthors(decimal.Parse(hdnProtocolVersionCKey.Value));
                //lstAuthors.DataTextField = "Name";
                //lstAuthors.DataValueField = "CKey";
                //lstAuthors.DataBind();
                //lstAuthors.Items.Insert(0, new ListItem("Please select"));
                ////lstAuthors.Attributes.Add("onchange", "setAuthor('" + lstAuthors.SelectedValue + "')");

                //DropDownList lstRoles = (e.Row.FindControl("lstRoles") as DropDownList);
                //lstRoles.DataSource = Role.getRoles(); //new Author().getAuthors(decimal.Parse(hdnProtocolVersionCKey.Value));
                //lstRoles.DataTextField = "RoleName";
                //lstRoles.DataValueField = "RoleCKey";
                //lstRoles.DataBind();
                //lstRoles.Items.Insert(0, new ListItem("Please select"));
                //lstRoles.Attributes.Add("onchange", "setRole('" + lstRoles.SelectedValue +"')");

                //lstAuthors.Items.FindByValue(country).Selected = true;
            }
            else if (e.Row.RowType == DataControlRowType.EmptyDataRow)
            {
                DropDownList lstAuthors = (e.Row.FindControl("lstAuthors") as DropDownList);
                lstAuthors.DataSource     = SSPUser.getAllAuthors(); //new Author().getAuthors(decimal.Parse(hdnProtocolVersionCKey.Value));
                lstAuthors.DataTextField  = "Name";
                lstAuthors.DataValueField = "CKey";
                lstAuthors.DataBind();
                lstAuthors.Items.Insert(0, new ListItem("Please select"));

                DropDownList lstRoles = (e.Row.FindControl("lstRoles") as DropDownList);
                lstRoles.DataSource     = Role.getRoles();
                lstRoles.DataTextField  = "RoleName";
                lstRoles.DataValueField = "RoleCKey";
                lstRoles.DataBind();
                lstRoles.Items.Insert(0, new ListItem("Please select"));
            }
            else if (e.Row.RowType == DataControlRowType.DataRow)
            {
                LinkButton EditButton   = (LinkButton)e.Row.FindControl("lnkEdit");
                LinkButton RemoveButton = (LinkButton)e.Row.FindControl("lnkRemove");
                Author     dataRecord   = (Author)e.Row.DataItem;
                if (EditButton != null && dataRecord != null)
                {
                    if (!Request.IsAuthenticated)
                    {
                        EditButton.Visible   = false;
                        RemoveButton.Visible = false;
                    }
                }

                if ((e.Row.RowState & DataControlRowState.Edit) > 0)
                {
                    DropDownList lstAuthors = (e.Row.FindControl("lstAuthors") as DropDownList);
                    lstAuthors.DataSource     = SSPUser.getAllAuthors();
                    lstAuthors.DataTextField  = "Name";
                    lstAuthors.DataValueField = "CKey";
                    lstAuthors.DataBind();

                    DropDownList lstRoles = (e.Row.FindControl("lstRoles") as DropDownList);
                    lstRoles.DataSource     = Role.getRoles();
                    lstRoles.DataTextField  = "RoleName";
                    lstRoles.DataValueField = "RoleCKey";
                    lstRoles.DataBind();

                    Author author = e.Row.DataItem as Author;
                    lstAuthors.SelectedValue = author.AuthorCKey.ToString();
                    lstRoles.SelectedValue   = author.RoleCKey.ToString();
                }
            }
        }