I am reading the contents of a list into a number of string variables so as to be able to build the content an HTML email.
The method I am using (and works for single line text boxes) is:
string Manager = item["Manager"].ToString();
However, when I try the same method for a multi-line text box I get the error:
Object reference not set to an instance of an object.
Can someone advise the best way in which to get the content of a multi-line text box into a variable that I can then reference for the other functionality mentioned?
The exception indicates that your item["Manager"] indexer does not find a column by that type. When it then tries to call .ToString() on it (null) it will result in the exception you are seeing.
Make sure you have the correct name (internal name, not display name!) for your notes column.
Or perhaps your instance of SPListItem the item variable is null.
When you try to get a OOB SharePoint Field it's best practice to use the SPBuiltInFieldId class or the ID of the Field instead of the internal name.
item[SPBuiltInFieldId.Title]
Related
I have some data in notepad and have performed Sendkeys("Ctrl+C") using keyboard library.I want to get the copied data to a variable in C# code.
How to get the data to variable programmatically.
I tried clipboard.GetText() API and it is giving empty string.
Your could get any data using Clipboard.GetDataObject().
See the example at msdn
From my C# code-behind I send a string value to my dataset. The data table also contains a field string type, which is dragged and dropped into Crystal Reports.
Now I need to divide that (string) value by some number, but strings can't be divided. So I need to convert the string to a value first - but I can't. No matter how I try to convert it always shows 0 on the report.
I created a formula called Euro:
NumericText({MYVALUE}) then ToNumber({MYVALUE})
And accessed it from another formula, EuroNum:
(If NumericText({Total}) then ToNumber ({Total}))
Then I created another field lets say TotalEuro where I did this in forumla, but it's always showing 0:
Euro/1.95
I used this formula:
If NumericText({VALUE}) Then ToNumber({VALUE}) / 1.955
Everything seems fine with Crystal Reports but I had problem in Visual Studio.
Even if this file is set up to copy everytime ,file somehow not copy changes to debug folder. So I manually moved this file to debug folder and everything was fine.
I'm working off a template document that has an existing Table of Contents object. I am having trouble identifying it and assigning it to a TableOfContents object programatically for further manipulation/updating.
I have examined the documentation for the TablesOfContents interface, and the only way I can see to return an object of the proper type is through the TablesOfContents.Add() function. I don't want to add a new TOC though. I just want to identify the one that already exists.
This seems to be explained in the documentation:
"The Document.TablesOfContents Property returns a TablesOfContents collection that represents the tables of contents in the specified document."
Once you have that, "Use TablesOfContents(index), where index is the index number, to return a single TableOfContents object. The index number represents the position of the table of contents in the document."
I am using the QuickBooks SDK in C# .NET to add /edit vendors in my QuickBooks. When I make a request with multiple errors, say like passing more than allowed number of characters for both Name field and Address1 field, QuickBooks always returns only the first error. It does not return all the errors that I make. How to return all the errors?
The status message says I am tryin to enter more than the allowed no of characters for the Name field, but doesn't mention anything about the Address field for which I am also passing more than allowed no of characters. If I pass a proper value for Name and make a error in Address1 field, then it gives me error in that field.
I want to get all the errors at one go. How can I get it?
I am looping through the ResponseList and displaying the error but the ResponseList.Count is also always 1. What is the way to get errors in all the fields that I am passing in a single request?
How to return all the errors?
You can't. QuickBooks itself does not support this - it always just returns the first error it runs into.
The allowed values, data lengths, and data types are very well defined in the XSDs/OSR. You should be able to easily build some validation into your own application to catch these errors/enforce correct data entry before submitting the data to QuickBooks.
I want to get all the errors at one go. How can I get it?
What is the way to get errors in all the fields that I am passing in a single request?
You can't. QuickBooks doesn't support this.
I have an SQL Server 2005 Express Reporting Server and I'm trying update a report to show a coloured label based on a value stored in the database.
I currently store the colour as an aRGB value, but I can change this if required.
I've seen posts on how to use expression in the color property, but I can't embed c# there.
Thanks!
SSRS uses VB.NET, not C#, and most places will accept code, it is prefixed with a '=' to let the parser know that it is code. I don't know exactly where you are trying to set the label (in a table, in a floating textbox, etc), but it is very likely that it is doable.
After some digging I found out that u have to use VB code.
Here's the steps.
Add a reference to System.Drawing in the report properties -> reference tab
Add this custom code to the report properties -> code tab
Public Function GetMyColour(myColour as integer) as string
Dim colorObj As System.Drawing.Color = System.Drawing.Color.FromArgb(myColour)
return String.Format("#{0:X2}{1:X2}{2:X2}", colorObj.R, colorObj.G, colorObj.B)
End Function
Set the color property expression on the report object you want set the color of to this
=Code.GetMyColour(First(Fields!RecipeColour.Value, "StockControl"))