Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Jump start: Any Add example
Message
 
To
28/02/2010 16:06:13
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01451594
Message ID:
01451657
Views:
25
Frank,

This is what I have done for a similar situation. This was advised to me by Kevin a couple of years ago and since it continues to work I haven't changed it. It may been done better using the Entity object but like I said it works for me now:
        this.cboControl.BindingType = mmBindingType.None;
        dsClient.Tables[0].Rows[0]["colName"] = this.cboControl.SelectedValue;
This turns off the binding on the combo box (which you could also do on the properties of the combo box) and sets the value of the column directly into the dataset which was established at the top of the click method. "colName" is the name of the column in your table.

Bob

>Thanks. I've got a problem when adding records. My editing works fine, but when I save from an Add, I am getting back a Concurrency violation. I've tracked it down to a combobox on my form that maintains a list of options that are hard code, not pulled from a table, for example: Male or Female.
>
>In my Save, I was setting the value of the Sex field to the SelectedValue of the combo, but that seems to trigger something in MM.NET to make it think it should run an Update rather than an Insert. So, I think the problem is how to configure the combo so that it uses a hard coded list, but gets bound to the datafield.
>
>I have tried by setting the BindingValueSource to my Business Object and the Binding ValueSourceMember to the name of the field, but that doesn't seem to set the value in the dataset so I get a RuleBroken that this field cannot be empty.
>
>How should I approach this?
>
>>Frank,
>>
>>The code for saving is no different for adding a record vs. editing a record. But here it is:
>>
>>
>> protected void btnSave_Click(object sender, EventArgs e)
>>    {
>>       
>>        DataSet dsClient = (DataSet)Session["dsClient"];
>>        if (this.Save(this.oClient, dsClient, this.oClient.TableName) == mmSaveDataResult.RulesPassed)
>>            mmMessageDisplay.DisplayMessage("System Confirmation", "Record Successfully Saved",
>>                "ClientsForm.aspx", 3);
>>    }
>>
>>
>>Note that I send the form back to the list form after successfully saving the record. If there were errors the edit form would remain with the error icons displayed.
>>
>>As far as unbound combos/dropdownlists, I am not sure what you mean. If these controls exist and they are not bound, what is their purpose? If they are bound to the business object then they will be part of the save process.
>>
>>>Hi Bob,
>>>
>>>that's pretty much exactly what I have. Can I see the code for saving? Also how do you handle unbound combos/dropdownlists?
>>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform