I have a button that will store the text value of 80 text boxes in winforms c#.
The button looks something like this at the moment
private void btnSaveChanges_Click(object sender, EventArgs e)
{
//Create new connection to the MongoDB Database and select the database and "table"
var nol = NetworkOpsLayer.NetworkOpsLayer.CreateForDirectMongoConnection("mongodb://snipip", "snipdbname", "snip");
//Inser the document starting with the selected node name, id, timestamp and then the entire loan data
nol.InsertDoc("{ \"LoanName\" : \"" + tvTodoList.SelectedNode.Name + "\", \"AgentName\" : \"" + txtAgentName.Text + "\" }");
}
This approach will work but I will end up with a string that is very long. nol.InsertDoc("{long JSON string of keys and textboxIDs}") as 80 textbox values each with their JSON key will be contained inside the string.
I'm wondering if there is a better way to go about this? Would it be possible to still form a valid JSON string by looping through each textbox on the form and give it a key that relates to the textbox so it's identifiable inside the MongoDB database?
StringBuilder.Appendto concatenate your string instead of+