problem in Retrieving rich text box sharepoint -
I need to get the value from a rich text box from the list. So far my code is this ..
array list arCategory = new Arrayist (); SPList myList = myWeb.Lists ["plist"]; SPQuery myQuery = new SPQuery (); MyQuery.Query = "& lt; OrderBy> ; SPListItemCollection myItemCol = myList.GetItems (myQuery); foreach (MyItemCol in SPListItem myItem) {String StrCatTxt = (string) myItem ["Category"]; - & gt;
// Category is the multiline rich text column
arCategory.Add (strCatTxt);} (for Ent J = 0; j & lt; arCategory.Count; J ++) {label; lblCategory = new label (); lblCategory.Text = arCategory [J] .Tostring (); ---- & quot; getting exceptions}
The problem here is SharePoint In your code, you have LblCategory.Text = arCategory [j] .sts Writing ();
If arCategory [j]
is null
, you get an exception when you call it on the toostring ()
So basically you can do it like Ix like it:
for (int j = 0; j & lt; arCategory.Count ; J ++) {if (arCategory [j]! = Null) {label; lblCategory = new Label (); LblCategory.Text = arCategory [J] .string (); ---- & gt; Getting Exception}}
Edit: Or, of course, you can add a & lt; Where & gt; ...
Element reads only the values in your question and from those items which are different from the category from null
will execute your query immediately!
Comments
Post a Comment