Ievgen
Ievgen

Reputation: 4443

Sharepoint 2010. Few simple questions

I have list definition.

 <ListInstance Title="tv2 - ListInstance3"
            OnQuickLaunch="TRUE"
            TemplateType="10002"
            Url="Lists/tv2 - tips status"
            Description="My List Instance">

1) How to add default items to this list? What will hapens when i will deploy this list with default items to server when customer will type his own items.

2)I have simple web part.

How can i set default items to web part fields?

   public string WebPartTitle { get; set; }

3) I need one web part (codebehind) but for customer will be very easy to view this part as three different web parts (in web parts list). The difference only in initial values. For example one web part with title "Block 1" and second with "Block 2" But actully it will be same code and same web part. How to do that? I hope sharepoint can do such easy thing)

4) How to set to page default web parts?

Upvotes: 1

Views: 516

Answers (3)

Rich Bennema
Rich Bennema

Reputation: 10345

For #1, you can do it directly in the XML:

<ListInstance Title="tv2 - ListInstance3"
            OnQuickLaunch="TRUE"
            TemplateType="10002"
            Url="Lists/tv2 - tips status"
            Description="My List Instance">
    <Data>
      <Rows>
        <Row>
          <Field Name='Title'>Default Item #1</Field>
        </Row>
        <Row>
          <Field Name='Title'>Default Item #2</Field>
        </Row>
        <Row>
          <Field Name='Title'>Default Item #3</Field>
        </Row>
      </Rows>
    </Data>
</ListInstance>

Upvotes: 1

Tomas Voracek
Tomas Voracek

Reputation: 5914

  1. You can add items after list is created. If you create list with default items then your customer can of course create new items.

  2. make field for property:

    public string webPartTitle;

    public string WebPartTitle { get{ return webPartTitle;} set{ webPartTitle=value; } }

  3. use inheritance. Base class will contain common logic.

  4. You probably mean having page layout with some default webparts already in it. Use webpartzone for that.

Upvotes: 2

BentOnCoding
BentOnCoding

Reputation: 28228

Create the sharepoint webpart exactly as you would if you were coding an asp.net custom control. When i used to make webparts for sharepoint and aside from heightened security restrictions it was very straight forward.

Upvotes: 2

Related Questions