I maintain a Silverlight 4 application. While I was out of the office, the database structure was changed and a table was dropped and its fields combined into another existing table. Now, I’m receiving the following error after I create a new item and proceed to its "summary" screen:
“Value cannot be null. Parameter name: Text
At System.Windows.Controls.TextBox.set_Text(String value)”
This only happens with newly created entries, not older entries where the information on the next screen is complete (data was converted from an Excel spreadsheet and loaded into the database). So, I’ve narrowed it down this: the child window that is used to create a new record doesn’t have all the fields that were added to the table because some of the information isn’t available when the record is created. A Google search turned up that null strings can’t be passed in Silverlight.
The Summary screen is loaded via ddsSummaryLoadedData domain service. If I don’t include the “new” fields, then the values aren’t loaded for existing entries, but new entries don’t cause an error. If I do include them, older entries load correctly but new ones give the above error.
Is there a workaround to create the empty fields until they’re needed, but still load data if it exists (for older entries)? Or does the child window need to be redesigned? I’m new to Silverlight and still have so much to learn!
It doesn't look like you're using Bindings to render your view otherwise null values will be handled gracefully, so if you are setting the Text property manually in code, use the cascading operator to verify you are not submitting a null value.
myTextBox.Text = myModelValue.FirstName ?? string.Empty;
Related
It's a struggle with any application that provides select fields, that are populated by a certain datasource: Everything works fine in the first place, but once the application ages, some older entries might be deleted, leading to the problem that prior select fields can no longer access the entity in question.
Opening a view, where a select points to an already deleted datarow will (best case) show empty string.
We designed our system in a way, that deletions are not real delete-operations, but only the setting of a deleted flag. (So, all the information is still there)
However, when using Databindings along with C# (or even if not) the most blatant use case is still not covered by general mechanics (I assume):
Select-Field should show all NOT-Deleted-Entities while creating a new object containing references to the entity in question.
Select-Field (populated the very same way) should show the "deleted" entity, if it was selected "days/months/years" ago.
Is there a "handy" solution to this?
Currently we are using a "Proxy-Method" for every datasource, which will reload the data of the deleted entity, if it's not in the "available data" collection - but it's hard to believe there is no better way to deal with this, as this problem applies for almost every language out there?
In a normalized database you would have a constraint with ON DELETE NO ACTION/RESTRICT event that would prevent removal of a referenced element from the list. It would force you to decide what is to be done with the referencing rows.
With your manually-controlled deletions this could have been covered by a trigger. As none of these were implemented, you are left with only one thing to do: updating the dropdown with the selected option before rendering the UI. My approach (in Java, I'm not good at C#):
List<String> options = getNonDeletedWhatever();
if (!options.contains(currentEntity.getWhatever())) {
options.add(currentEntity.getWhatever()); // This optionally inserts an outdated value
}
or simply:
Set<String> options = getNonDeletedWhatever();
options.add(currentEntity.getWhatever()); // This optionally inserts an outdated value
I solve it by creating a list of available (non-deleted) items and if the selected item is a deleted one, then I add that item to the list.
This list becomes the data source for my dropdown.
I'm developing a win forms application using AxosoftAPI.NET. I've implemented functionality to search for Items like Tasks, Defects, Incidents and Projects.
I can also check whether an Item has attachments. Now I need to know how to check if an Item (Task or Defect) has an Install or Testing Note attached to it. I searched in Axosoft's developers website but couldn't find anything helpful. How can I achieve this in C# using AxosoftAPI.NET?
Install and Testing Notes are not standard fields in Axosoft so are most likely Custom Fields that were added by your team. All custom fields should be returned when getting items, however large text fields, are only returned when getting a single item, rather then getting lists of items.
From the developer.axosoft.com page regarding the GET multiple and specifying the columns parameter :
(comma seperated string) Containins the names of the columns to return for each item. Defaults to all columns. However, please note that for performance reasons long text fields (such as 'Description') are not returned by this API call. To get the values of long text fields, use the GET /defects/{id} call to retrieve a single item.
I'm having some serious issues with setting an items values be _StandardValues in sitecore. I have a sitecore item and I retrieve it's data simply thus:
Item rawItem = service.Database.GetItem(new ID(id));
I subsequently extended said item's template and added a new TreeListEx. I populated this treelist from standard values:
The problem is the standard values are not getting retrieved by the above code. The field does not exist in the fields collection. What is confusing is if I change the items values, so remove all the standard items and put them back in, it works. The only thing in the UI appears different is that the field goes from:
to
i.e. it's not pulling this data from [standard values] anymore. I can now see my fields in rawItem (above).
If I check the Raw values of the they are identical (i.e. a collection of Guids as you'd expect):
{4E4A364E-16D5-4E09-A4E7-25DB628951FB}|{15E4026A-575A-4787-83B0-A37EB9F0A06D}|{74D1C654-BE53-4FB4-A072-19DA70215F4B}|{C3883CDE-A01E-46B7-B09F-2FB1F4C51C3A}
Has anyone else experienced this issue? Am I missing something?
I think I got a solution, it just came back to life. It appears that I needed to rebuild the link DB. I had tried this previously to no avail, but the difference this time is I rebuilt all 3 (core, web and master) DBs:
Hopefully this will help someone with this issue in the future.
I have a TreeView, and am using a DataReader to populate it with data from specific columns in the database, specifically "consultationDate" (and another one beginning with the same name, just append "Notes" onto the end of that one, to get "consultationNotes).
The thing is, as soon as it gets around to executing the code that is meant to add the notes to the tree view, it tell me that I have an IndexOutOfBoundsException. The columns concerned do have data in them.
The code is below.
Any ideas as to why I am getting that error?
while (treeNodeReader.Read())
{
//childNode = parentNode.Nodes.Add("Note Details: " + treeNodeReader["consultationNotes"].ToString());
}
(For ease of readability, because the issues is the same for both columns, I've included only one column's code here).
I have a relatively complex dataset (numerous tables, some with multiple records) generated from reading in an XML file. I need to connect said dataset fields to an ASP form. At the moment I'm assigning them manually, like so in the pageload:
txt_first_init.Text = formData.ds.Tables["phrmHdrKey"].Rows[0]["first_init"].ToString();
txt_last_name.Text = formData.ds.Tables["phrmHdrKey"].Rows[0]["last_name"].ToString();
ddl_pregnancy_flag.SelectedValue = formData.ds.Tables["pPhrm"].Rows[0]["pregnancy_flag"].ToString();
And conversely when it's time to submit.
formData.ds.Tables["phrmHdrKey"].Rows[0]["first_init"] = txt_first_init.Text;
formData.ds.Tables["phrmHdrKey"].Rows[0]["last_name"] = txt_last_name.Text;
formData.ds.Tables["pPhrm"].Rows[0]["pregnancy_flag"] = ddl_pregnancy_flag.SelectedValue.ToString();
I did some looking into binding the textboxes (and dropdownlists, and checkboxes, and and and...) directly, but it seemed to be too many formats to use.
So this works fine, but as the number of fields increases, those load and unload lists are going to get unwieldy.
Trying to come up with a way to make a future update or addition so said list neater. I've gotten a very hand-wavy suggestion to place the two columns of names into a list, but unsure how to set such up, and how to load the items into a function that could evaluate and run the resulting commands.
Thoughts?
see here: Dynamic Form Generation in ASP.NET
looks like MS Dynamic Data is the answer.