0
votes

I am having One Table in Sql server 2008 R2. In SQL server I have Created a view having 5 Column . I want to Display Same view in Sharepoint 2010 .

For Displaying Purpose I Used BCS and Extenal List ,then I get All Records in Sharepoint Extenal List . But here my Problem Is That I wanted to Add One more Column Attachement With That . I didnt get Any Success On It .

Now I am using Custom List .And by Using SSIS I am Exporting the record from SQl Server to sharepoint List. It Is having Default Option for Attachement ,But Here My Problem Is that Users are able to Edit Remaining columns from Custom List. I want Only Attachment and Remaing columns should be ReadOnly.

Any one Please let me know the Solution for :

How can I add Attachment Column into External List into Sharepoint 2010 . Or .

How can I make Other Column Read Only Except Attachement ..

1

1 Answers

0
votes

You should be able to set fields programmatically. You can use an event receiver to target when you need to do it. Check out this article.

When created items in SharePoint via the object model, you can convert a readonly property of that field to be false in order to allow you to set the value of that field or vice versa. You can set them back and forth to read only fairly easy.

// get the list and set modified property to allow writing
SPWeb web = new SPSite("http://url/to/web").OpenWeb();
SPList selectedList = web.Lists["listname"];
selectedList.Fields["Modified"].ReadOnlyField = false;
selectedList.Fields["Modified"].Update();


// set the item
SPItem newItem = selectedList.Items[0];
newItem["Modified"] = DateTime.Now;
newItem.Update();

// Set readonly back to true
selectedList.Fields["Modified"].ReadOnlyField = true;
selectedList.Fields["Modified"].Update();