protected void btnAddAttribute_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(tbAttrName.Text))
        {
            lbErrorText.Text = (string)GetLocalResourceObject("noAttrNameData");
            lbErrorText.Visible = true;
            return;
        }

        PersonAttributeType attr = new PersonAttributeType();
        if (UserAttributeId > 0)
        {
            attr.Load(UserAttributeId);
            UserAttributeId = -1;
        }
        else
        {
            if (PersonAttributeType.GetAttributeType(tbAttrName.Text) != null)
            {
                lbErrorText.Text = (string) GetLocalResourceObject("isAttrError");
                lbErrorText.Visible = true;
                return;
            }
        }

        attr.AttributeName = tbAttrName.Text;
        attr.ShowToUsers = cbShowToUsers.Checked;
        attr.Save();

        clearData();
    }
    private void gvAttributes_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int id = (int)gridViewAttributes.DataKeys[e.RowIndex].Value;
        PersonAttributeType attr = new PersonAttributeType();
        if (!attr.Load(id))
            return;

        attr.Delete();
        //bindAttributesGridView();
    }
    public string AllUserInfoPrint(string SrtringField, int AttributeID)
    {
        string typeAtr = ddlTypeSelect.SelectedItem.ToString();
        if (typeAtr.Equals("All"))
        {
            PersonAttributeType attr = new PersonAttributeType();
            attr.Load(AttributeID);
            return string.Format("{0} - {1}"
                                 , attr.AttributeName
                                 , SrtringField);
        }

        return SrtringField;
    }
    protected void attributeBinding()
    {
        PersonAttributeType attr = new PersonAttributeType();
        attr.Load(UserAttributeId);

        tbAttrName.Text = attr.AttributeName.Trim();
        cbShowToUsers.Checked = attr.ShowToUsers;

        tbAttrName.Enabled = Enum.IsDefined(typeof (PersonAttributeTypes), attr.AttributeName.Trim())
                                 ? false
                                 : true;

        lbErrorText.Visible = false;
    }
    public string UserKeyWordPrint(int AttributeID)
    {
        string typeAtr = ddlTypeSelect.SelectedItem.ToString();
        PersonAttributeType attr = new PersonAttributeType();

        if (!attr.Load(AttributeID))
            return string.Empty;

        return typeAtr.Equals("All")
                   ? attr.AttributeName
                   : string.Empty;
    }