.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Custom List with attachment problem

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :C#

Sharepoint 2007:

I created a custom list and the user can attach two files that is stored in listitem.attachments.

I try to give the user a delete button but when I perform the delete I get an error.

When I press the delete (image button) the page postback and if I click for example another button (a save button or an add attachment button) it raises an SP Exception (No item exists at http://server/site/Pages/edit.aspx?id=37. It may have been deleted or renamed by another user). If I go to the list and then return in the item everything is fine.

In order to add the attachment I am using the following code:

if (FileUpload.PostedFile != null && FileUpload.HasFile)
    Stream fStream = AnswerFileUpload.PostedFile.InputStream;
    byte[] contents = new byte[fStream.Length];
    fStream.Read(contents, 0, (int)fStream.Length);
    SPAttachmentCollection attachments = myItem.Attachments;
    string FileName = Path.GetFileName(AnswerFileUpload.PostedFile.FileName);
    attachments.Add(FileName, contents);



View Complete Post

More Related Resource Links

Problem with SharePoint Designer 2007 and Custom List Forms


I created several forms (Create/Edit/View) for a SharePoint list, using Custom List Forms.  I'm using Content Types in the list to ensure that each item only has the necessary fields.  When I created the ASPX forms, and inserted the Custom List Forms, I selected the correct Content Type, and I got the right fields inserted in the form.

Now, for some reason I can't identify, every time I create a new form, and insert a Custom List Form, SPD is bringing ALL fields from the list, instead of just bringing the fields included in the selected Content Type.

I have tried many different things to solve the problem, including creating new lists/content types/forms, etc. but SPD is doing the same thing all the time.

Can somebody tell me what may have gone wrong in SPD or MOSS?


Display Images from a Custom List's Attachment Field

i need to show each item on the list with image that was uploaded to its attachments field. the idea is that this list is a news list and will be show as a grid with the news and their corresponding attached image. i tried to add a custom column of type Picture, but it only allows to have a hyperlink added. i need the ability to upload the image on a new item creation form.   if there is a way to display it that would be great, if not please recommend a way to accomblish what i have explained.     thanks  

SharePoint Custom List Attachment to Store URL and Not a File


I need to ust the attachment column for a list, but I want to store the URL NOT the attached file.  I could use a Link Column type, but doesn't have the browse utility that the attachement column has. 

Any ideas?  I would like to store the URL and not the FILE with the browse utility

Problem while creating a column in custom list

I am using sharepoint 2010 beta2

I tried to create a column in custom list using a button in ribbon as well as in list settings page

After filling the data and clicking on 'OK' button I am getting a JavaScript error and form is not being submitted

Javascript error details:

Message: 'undefined' is null or not an object
Line: 1423
Char: 4
Code: 0

Problem with creating Custom List in SharePoint Designer


Hello all,

I have used SharePoint designer 2007 to create a custom list for my SharePoint 2003 portal.  The list is quite simple, without any extensive programming. 

First I created a 'shell' for my list inside of SharePoint, where I name my fields and select their input types (Choice, Date, Currency, etc).

I then create a new .aspx file, insert a Custom SharePoint List into the new file, and use the above mentioned 'shell' to insert my content.

From this point, I rearrange the design, insert a few basic JavasScript elements - for image rollovers - and save.

The page displays perfectly in my live SharePoint environment.  However, when I enter data into this form, and submit, it doesn't save the data correctly.  For instance, there's a Yes/No option near the end of the form, defaulted to No.  If I click that checkbox - to set it to Yes - and submit the form, the resulting record does not show that I had clicked the checkbox.  In fact, it shows the whole form as being blank, as if I had entered nothing at all.

If this makes sense, how would I go about fixing this?

problem...i want a list item to populate all data in gridview!!!


i have a dropdownbox and a gridview

what I want is to have a list item which populates all data in a gridview.

I have tried using list item selected value=0 but to no avail.

what is the easiest way to achieve this?

How to add custom list entries to mysite's calendar in Sharepoint 2007 site?


I would like to know below things

(1) How to create MySite for one specific member with other or administrator's access?

(2) Scenario : Administrator have created one SP2007 site. now Administrator have created one calendar (Sample calendar). Administrator have added some entries in calendar. now one user entered in portal site ansd view the calendar and he click on MySite menu. so this sample calendar entries should enter in that user's mysite calendar. How this can be achieved?

Thanks in advance.
Regards, Praful Udade

Picker returns nothing for BDC column in custom list


Playing with the BDC for the first time, running into some issues adding a Business Data column to a custom list.

I believe my ADF file is solid. I've been able to import that just fine and can use the application to drive various BDC-specific webparts (a Business Data List or Business Data Item, for example). It also seems to work when I manually enter information in my NewForm.aspx field and click the Check Names button (it verifies my entry and underlines it, creates link to profile when I view the list data).


If I try to use the picker, I get nothing. Enter a name I know is valid or a % and click the magnifying glass icon and I very briefly get the "Please Wait" message, then just an empty set with "Type into the search box above then press "Enter" to start your search" where my results should be.

Any pointers? Thanks.

SharePoint Designer: insert custom list not working anymore



Suddenly sharepoint designer decided today that it doesn't want to insert a custom list form anymore...
To be more specific, it doesn't work anymore in a site that uses the Microsoft budgeting and tracking template. In a website that uses an out of the box template, it still works.

It did work before, because I did it in other websites using the same template (it's broken there as well now).

Why oh why does SharePoint refuse to do this now?
I searched google and here on the forums, but all I could find was some issues after installing SP1, but we did that already long time ago and it was still working after that. I checked with our infrastructure guys and they didn't install new updates they say.

I also tried the solutions listed here: http://blogs.msdn.com/spdsupport/archive/2008/07/03/how-to-fix-custom-list-forms-will-not-insert-or-show-up-on-the-design-surface-of-sharepoint-designer.aspx
But they don't fix the problem.

So my problem is, I can go to Insert > SharePoint Controls > Custom List Form
I pick my list, content type and form type, I hit OK and... nothing happens.

How to enable check in check out functionality for a custom list?



how could i enable check in check out functionality for a custom list? I know this exists for document libraries, but isnt this possible for custom lists?

Best regards,
Yavuz B.

My Blog http://www.starcoder.net

Need to pass parameters from URL to fields in Custom List


I have a complex customized list and I need to pass parameters of two fields so that when the 'Questionnaire' is completed and subsequentially opened after initial submission, it will retrieve the Number and GUID automatically in respective fields. I send an email out with a link to the 'Form' that carries the parameters. I am trying to use the following javaScript but am unsure as to where to place this on the SharePoint page for it to work.



<script type="text/javascript">

function loadFormVars()
getQuerystring('CustodianGUID', 'ctl00_m_g_d08916d8_7224_4665_be72_2de381f45985_ff46_1'); ///replace
customerGUID and form field name
'ctl00_m_g_d08916d8_7224_4665_be72_2de381f45985_FormField11_ctl00_ctl00_TextField'); ///replace customerGUID
and form field name

alert("it works");

function getQuerystring(key, field)
key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
var qs = regex.exec(window.location.href);
document.getElementById(field).value = qs[1];


Cascade Drop Down List Problem


I have 4 "cascade drop down linked" each other. The first one is "AccesoryFor", the second "TypeOfAccesory", the third "MarkOfAccesory" and the fourth "ModelOfAccesory".

The problem is that sometimes is possible in the web page I'm programming that a "Session Variable" could have a value that must be selected in one of that ddls. But not only that, the "ddl" or the entire "row" where the ddl is located ,must disappear. The problem is that, when the page does the rendering process, the others "cascade drop down" don't find its "control parents", so they stay disable and without data.

So, what I do in the Load Method:

 protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)
            Session["AccesoryFor"] = "cellphone";

 public void loadValuesToUI()
    if (Session["consultarRecursos_AccesorioDe"] != null)
            rowAccesoryFor.Visible = false;

As the row where the first DLL is located dissapears, and error occurs saying that "Control-Parents" are not found. There's no way to "Disable" or make dissapear the ddl in the web-service because

Problem with list controls and update progress template



I have an update panel that surrounds a wizard control which I use in conjunction with a update progress control. Now my update progress control works perfectly, with my animated gif and div tag that lays over my wizard control when the user goes from step to step. However, there is a problem that I am struggling to solve. A number of my steps use controls like list boxes, and when the update progress control fires, the list control is not laying underneath my div an animated gif no matter how high a make my css z-index on the div.

Does anyone have a way of solving this?


Quick Note: Create Custom List Definitions in SharePoint 2010

In this exercise, you create a custom list definition in Microsoft SharePoint 2010 and then create an event receiver that is triggered when the list is used.

Creating List Definitions with Custom List Columns for SharePoint Server 2007

Learn to use Visual Studio 2008 Extensions for Windows SharePoint Services to create a SharePoint list definition that implements custom list columns.

Importing SharePoint List Data into Project Server 2007 Custom Fields

Learn how to use the programmability features of Project Server 2007 and Windows SharePoint Services 3.0 to import SharePoint list data into an enterprise custom field.

c# form problem with list item


I've got a c# form containing a listbox how ever i cant get

listbox1.items.Selected      to work



neither work. both not giving me the option for .selected nor selectedvalue

how does this work on c# forms as it works the above way on webforms....

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend