Bonjour, j'ai réalisé un custom Field qui contient une liste déroulante. J'ajoute sans problème le custom Field dans la liste mais quand je crée un nouveau item je ne vois pas le dropdownList dans le champ spécifié :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
 
<%@Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.WebControls"%>
 
<SharePoint:RenderingTemplate ID="AnneeCustomFieldControl" runat="server">
 
    <Template>
        <asp:DropDownList runat="server" ID="DropDownListAnnee" />
    </Template>
 
</SharePoint:RenderingTemplate>
 
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
 
namespace AnneeCustomField
{
    public class AnneeCustomField : SPFieldChoice
    { 
 
 
 
        public AnneeCustomField(SPFieldCollection fields, string fieldName)
            : base(fields, fieldName)
        {
            //this.Choices.Add("2007");
            //this.Choices.Add("2008");
            //this.Choices.Add("2009");
            //this.DefaultValue = "2007";
        }
        public AnneeCustomField(SPFieldCollection fields, string typeName, string displayName)
            : base(fields, typeName, displayName)
        {
            //this.Choices.Add("2007");
            //this.Choices.Add("2008");
            //this.Choices.Add("2009");
            //this.DefaultValue = "2007";
        }
 
        public override BaseFieldControl FieldRenderingControl
        {
            get
            {
                AnneeCustomFieldControl AnneeCustomFieldControl = new AnneeCustomFieldControl();
 
                AnneeCustomFieldControl.FieldName = InternalName;
 
                return AnneeCustomFieldControl;
            }
        }
    }
 
}
 
 
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.Configuration;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint.WebControls;
 
namespace AnneeCustomField
{
    class AnneeCustomFieldControl : BaseFieldControl
    {
        public class ActiveDirectoryUserQueryFieldControl : BaseFieldControl
        {
            protected DropDownList DropDownListAnnee;
 
            protected override string DefaultTemplateName
            {
                get
                {
                    //Return the name of the ascx 
                    return "AnneeCustomFieldControl";
                }
            }
 
            public override object Value
            {
                get
                {
                    EnsureChildControls();
                    return DropDownListAnnee.SelectedValue.ToString();
                }
 
                set
                {
                    EnsureChildControls();
                    DropDownListAnnee.SelectedValue = (string)this.ItemFieldValue;
                }
            }
 
            //Make sure that the combo box gets focus whenever the field does.
            public override void Focus()
            {
                EnsureChildControls();
                DropDownListAnnee.Focus();
            }
 
            protected override void CreateChildControls()
            {
 
                if (Field == null) return;
 
                base.CreateChildControls();
 
 
                if (ControlMode == Microsoft.SharePoint.WebControls.SPControlMode.Display)
                    return;
 
                //Get the combo box from the template.
                DropDownListAnnee = (DropDownList)TemplateContainer.FindControl("DropDownListAnnee");
 
                if (DropDownListAnnee == null)
                {
                    throw new ArgumentException("cboUsers is null. Corrupted ActiveDirectoryUserQueryFieldControl.ascx file.");
                }
 
                if (!Page.IsPostBack)
                {
                    try
                    {
                        //Populate the combo box with user names.
                        DropDownListAnnee.Items.Add("2005");
                        DropDownListAnnee.Items.Add("2006");
                        DropDownListAnnee.Items.Add("2007");
                    }
                    catch (Exception ex)
                    {
 
                    }
                }
            }
        }
 
 
    }
}

J'ai essayé de voir tout sur le net j'ai appliqué les mêmes trucs mais bizarre !
J'espère que vous puissiez m'aider