private void BindAnswerOptions()
        {
            if (NSurveyUser.Identity.IsAdmin ||
                NSurveyUser.Identity.HasAllSurveyAccess)
            {
                _answerTypes = new AnswerTypes().GetAnswerTypesList();
            }
            else
            {
                _answerTypes =
                    new AnswerTypes().GetAssignedAnswerTypesList(NSurveyUser.Identity.UserId, getSurveyId());
            }

            AnswerTypeDropDownList.DataSource = _answerTypes;
            AnswerTypeDropDownList.DataMember = "AnswerTypes";
            AnswerTypeDropDownList.DataTextField = "Description";
            AnswerTypeDropDownList.DataValueField = "AnswerTypeID";
            AnswerTypeDropDownList.DataBind();
            TranslateListControl(AnswerTypeDropDownList);
            AnswerTypeDropDownList.Items.Insert(0,
                new ListItem(GetPageResource("SelectTypeMessage"), "-1"));
            AnswerTypeDropDownList.SelectedValue = "1";
            _answers = new Answers().GetAnswers(_parentQuestionId, ChildsLanguageDropdownlist.SelectedValue);
            ColsDataGrid.Columns[2].Visible = RatingCheckbox.Checked;
            ColsDataGrid.DataSource = _answers;
            ColsDataGrid.DataMember = "Answers";
            ColsDataGrid.DataKeyField = "AnswerId";
            ColsDataGrid.DataBind();
        }
        /// <summary>
        /// Get the current DB data and fill 
        /// the fields with them
        /// </summary>
        public void BindFields()
        {
            // Retrieve the answer type data
            AnswerTypeData answerTypeData = new AnswerTypes().GetAnswerTypeById(AnswerTypeId);
            AnswerTypeData.AnswerTypesRow answerType = answerTypeData.AnswerTypes[0];

            if (answerType.BuiltIn)
            {
                DeleteTypeButton.Attributes.Add("onClick",
                    "javascript:if(confirm('" + ((PageBase)Page).GetPageResource("DeleteBuiltInTypeConfirmationMessage") + "')== false) return false;");
                ApplyChangesButton.Attributes.Add("onClick",
                    "javascript:if(confirm('" + ((PageBase)Page).GetPageResource("ApplyBuiltInChangesConfirmationMessage") + "')== false) return false;");
            }
            else
            {
                DeleteTypeButton.Attributes.Remove("onClick");
                ApplyChangesButton.Attributes.Remove("onClick");
                MakeBuiltInButton.Attributes.Add("onClick",
                    "javascript:if(confirm('" + ((PageBase)Page).GetPageResource("MakeBuiltInConfirmationMessage") + "')== false) return false;");
            }


            // Assigns the retrieved data to the correct fields
            TitleTextBox.Text = answerType.Description;
            if (answerType.XmlDataSource !=
                null && answerType.XmlDataSource.Length != 0)
            {
                XmlFileNameTextbox.Text = answerType.XmlDataSource;
                DataSourceDropDownList.SelectedValue = "2";
            }
            else if (answerType.DataSource !=
                null && answerType.DataSource.Length != 0)
            {
                SqlQueryTextbox.Text = answerType.DataSource;
                DataSourceDropDownList.SelectedValue = "3";
            }
            else
            {
                DataSourceDropDownList.SelectedValue = "1";
                SelectionTypeCheckBox.Checked =
                    (((AnswerTypeMode)answerType.TypeMode & AnswerTypeMode.Selection) > 0);
                FieldTypeCheckBox.Checked =
                    (((AnswerTypeMode)answerType.TypeMode & AnswerTypeMode.Field) > 0);

                FieldShownInResultsCheckBox.Checked = answerType.PublicFieldResults;
                FieldHeightTextBox.Text = answerType.FieldHeight.ToString();
                FieldWidthTextBox.Text = answerType.FieldWidth.ToString();
                FieldMaxLengthTextBox.Text = answerType.FieldLength.ToString();
                JavascriptFunctionNameTextBox.Text = answerType.JavascriptFunctionName;
                JavascriptTextBox.Text = answerType.JavascriptCode;
                JavascriptErrorMessageTextBox.Text = answerType.JavascriptErrorMessage;

                RichFieldLabel.Visible = !SelectionTypeCheckBox.Checked;
                RichFieldCheckBox.Visible = !SelectionTypeCheckBox.Checked;
                if (SelectionTypeCheckBox.Checked)
                {
                    RichFieldCheckBox.Checked = false;
                }
                else
                {
                    RichFieldCheckBox.Checked =
                        answerType.TypeNameSpace == "Votations.NSurvey.WebControls.ThirdPartyItems.FreeTextBoxAnswerItem";
                }
            }

            if ((answerType.BuiltIn && !((PageBase)Page).NSurveyUser.Identity.IsAdmin) ||
                (DataSourceDropDownList.SelectedValue == "3" &&
                (!GlobalConfig.SqlBasedAnswerTypesAllowed ||
                !((PageBase)Page).CheckRight(NSurveyRights.SqlAnswerTypesEdition, false))))
            {
                ApplyChangesButton.Visible = false;
                DeleteTypeButton.Visible = false;
                MakeBuiltInButton.Visible = false;
                if (DataSourceDropDownList.SelectedValue == "3"
                    && !((PageBase)Page).CheckRight(NSurveyRights.SqlAnswerTypesEdition, false))
                {
                    DataSourceDropDownList.Enabled = false;
                }
                else
                {
                    DataSourceDropDownList.Enabled = true;
                }
            }
            else if (answerType.BuiltIn && ((PageBase)Page).NSurveyUser.Identity.IsAdmin)
            {
                ApplyChangesButton.Visible = true;
                DeleteTypeButton.Visible = true;
                MakeBuiltInButton.Visible = false;
                DataSourceDropDownList.Enabled = true;
            }
            else
            {
                ApplyChangesButton.Visible = true;
                DeleteTypeButton.Visible = true;
                MakeBuiltInButton.Visible = ((PageBase)Page).NSurveyUser.Identity.IsAdmin;
                DataSourceDropDownList.Enabled = true;
            }

            InitUserInterface();
        }
		private void AnswerTypeDropDownList_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			AnswerTypeData typeData = new AnswerTypes().GetAnswerTypeById(int.Parse(AnswerTypeDropDownList.SelectedValue));
			SetUIState(typeData.AnswerTypes[0].TypeMode, true);
		}
		private void Page_Load(object sender, System.EventArgs e)
		{
			LocalizePage();

			MessageLabel.Visible = false;
			DeleteAnswerButton.Attributes.Add("onClick",
							"javascript:if(confirm('" +((PageBase)Page).GetPageResource("DeleteAnswerConfirmationMessage")+ "')== false) return false;");
		
			if (!Page.IsPostBack)
			{
				BindData();
			}

			AnswerTypeData typeData = new AnswerTypes().GetAnswerTypeById(int.Parse(AnswerTypeDropDownList.SelectedValue));
			SetUIState(typeData.AnswerTypes[0].TypeMode, false);
		}
        /// <summary>
        /// Generates the templated column with the
        /// selection mode
        /// </summary>
        private void AnswersDataGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
        {
            DataGridItem gridItem = (DataGridItem)e.Item;
            if (gridItem.ItemType != ListItemType.Footer && gridItem.ItemType != ListItemType.Header)
            {
                AnswerTypeData typeData = new AnswerTypes().GetAnswerTypeById(int.Parse(_answers.Answers[gridItem.DataSetIndex].AnswerTypeId.ToString()));
                gridItem.Cells[3].Text = GetPageResource(typeData.AnswerTypes[0].Description) != null ?
                    GetPageResource(typeData.AnswerTypes[0].Description) : typeData.AnswerTypes[0].Description;

                int typeMode = int.Parse(DataBinder.Eval(e.Item.DataItem, "TypeMode").ToString());
                bool ratePart = (bool)DataBinder.Eval(gridItem.DataItem, "RatePart");

                //				// Can this answer be selected ?
                if ((((AnswerTypeMode)typeMode & AnswerTypeMode.Selection) > 0))
                {
                    if (MultipleSelection)
                    {
                        CheckBox check = (CheckBox)gridItem.Cells[1].FindControl("DefaultCheckBox");
                        check.Checked = (bool)DataBinder.Eval(e.Item.DataItem, "Selected");
                        check.Visible = true;
                    }
                    else
                    {
                        GlobalRadioButton radio = (GlobalRadioButton)gridItem.Cells[1].FindControl("DefaultRadio");
                        radio.Checked = (bool)DataBinder.Eval(e.Item.DataItem, "Selected");
                        radio.Visible = true;
                    }

                    if (ratePart)
                    {
                        ((Label)gridItem.FindControl("RatingLabel")).Text = _currentRating.ToString();
                        _currentRating++;
                    }
                    else
                    {
                        ((Label)gridItem.FindControl("RatingLabel")).Text = "0";
                    }

                    if (_scoreEnabled)
                    {
                        if (DataBinder.Eval(e.Item.DataItem, "ScorePoint") != null &&
                            DataBinder.Eval(e.Item.DataItem, "ScorePoint").ToString().Length > 0)
                        {
                            ((Label)gridItem.FindControl("ScorePoint")).Text = DataBinder.Eval(e.Item.DataItem, "ScorePoint").ToString();
                        }
                        else
                        {
                            ((Label)gridItem.FindControl("ScorePoint")).Text = "0";
                        }
                    }
                }
                else
                {
                    gridItem.Cells[1].FindControl("DefaultRadio").Visible = false;
                    gridItem.Cells[1].FindControl("DefaultCheckBox").Visible = false;
                    ((Label)gridItem.FindControl("RatingLabel")).Text = "n/a";
                    ((Label)gridItem.FindControl("ScorePoint")).Text = "n/a";
                }
            }

        }
        private void BindAnswerOptions()
        {
            _answerTypes = new AnswerTypes().GetAnswerTypes();
            _answers = new Answers().GetAnswers(_questionId, LanguagesDropdownlist.SelectedValue);
            if (_answers.Answers.Rows.Count > 0)
            {
                AnswersDataGrid.Visible = true;
                AnswersDataGrid.DataSource = _answers;
                AnswersDataGrid.DataMember = "Answers";
                AnswersDataGrid.DataKeyField = "AnswerId";
                AnswersDataGrid.DataBind();
            }
            else
            {
                AnswersDataGrid.Visible = false;
            }

        }