Below is the code snippet of what i am trying to do.
dynamic model = new ExpandoObject();
foreach (Control control in ConfigData.ActiveForm.Controls)
{
string controlType = control.GetType().ToString();
if (controlType == "System.Windows.Forms.TextBox")
{
TextBox txtBox = (TextBox)control;
if (string.IsNullOrEmpty(txtBox.Text))
{
MessageBox.Show(txtBox.Name + " Can not be empty");
return;
}
model[txtBox.Name] = txtBox.Text; // this gives error
}
}
here i want to create a property with name of the value came from txtBox.name
for example if value of textBox.name="mobileNo" i want to add a property with name mobileNo to model. how to do that?