Reputation: 64
I am using C# windows forms with entityframework 6.1.3 as the datasource.I am tryng to insert data into a windows form. I have searched for various guides but all of them show an example like this
private void CreateCash(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
LegalGridView.AddNewRow();
LegalGridView.ShowPopupEditForm();
var CashBookCreate = new CashBook
{
CashTransact = cashtransacts.Name
};
dbContext.CashBooks.Add(CashBookCreate);
dbContext.SaveChanges();
}
}
CashTransact is the name of my class and in that format it enters "Legal Fees" in the database but I want to substitute "Legal Fees" for the value in my textbox 'cashtransacts' which unfortunately when I replace it there as cashtransacts.Name instead gets me the name of the column instead of the value I type in?
Upvotes: 0
Views: 603
Reputation: 1286
"value in my textbox"
The correct way to get a value from a textbox is TextBox.Text.
The TextBox.Name will only return the name of the control that you provided it.
Upvotes: 1