0

Web パーツのアクティブ化時に、相互にリンクされた 2 つのリストをプログラムで作成しようとしています。

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
    SPWeb spWeb = properties.Feature.Parent as SPWeb;
    if (spWeb != null)
    {
        // Create our Lists
        spWeb.Lists.Add("Memeber Records", "Holds a list of Memebers", SPListTemplateType.GenericList);
        spWeb.Lists.Add("Certification", "Certifications and Their Descriptions", SPListTemplateType.GenericList);

        SPList list = spWeb.Lists["Memeber Records"];
        SPList certList = spWeb.Lists["Certification"];

        // Add Outr Fields
        list.Fields.Add("Memebr ID", SPFieldType.Integer, true);
        list.Fields.Add("Memeber Name", SPFieldType.Text, true);
        // were missing a item - a drop down with static content such as: Association, Company, Head Office
        list.Fields.Add("Memeber Certification", SPFieldType.Lookup, false);

        list.Update();

        certList.Fields.Add("Certfication Title", SPFieldType.Text, true);
        certList.Fields.Add("Description", SPFieldType.Text, true); // This one should be a text box allowing 256 characters

        certList.Update();
    }
}

ご覧のとおり、さらにいくつかのものを作成する方法を理解するために、あなたの助けが必要です。

  • フィールドとして静的コンテンツを含むドロップダウンが必要です。ただし.Fields.Add()、ドロップダウン機能はありませんlist
  • certListの 2 番目のフィールドは、最大 250 文字のテキスト ボックスであると想定されています。
  • メンバー認定certListlist選択するときに、certtList

この Web パーツのアクティブ化時にこれを機能させるために欠けているものは他にありますか? 私はそれをサイトにスコープしましたが、デプロイするとき (プロジェクトを作成したときに選択しました)、サンドボックスではなくそのファームを

4

1 に答える 1

1

選択フィールドを使用してみましたか。list.Fields.Add には、選択肢も入力できるオーバーロードがあります。試したことはありませんが、これは特に選択フィールド用です。

于 2013-06-12T11:37:24.667 に答える