I have a private method that returns me as a result of the execution of a data set.
What I want to do is reference in this method a textBox that I have in the main button of my Windows Form application. For the user to manually enter the 'Caption', this new caption will be replaced by the one already in place.
The textBox I can call it without problems to patir of the button1_click but not from my method.
I get the error an object reference is required to access non-static field method or property
Here is the method in which I am trying to call textBox4.
How could I do that?
static private string GetMappingTable()
{
string SourceID = "";
var ds = GetMappingTable();
foreach (DataTable dst in ds.Tables)
{
foreach (DataRow dr in dst.Rows)
{
//Aqui me aparece el error
if (textBox4.Text != "");
var DataSourceId = ds.Tables["Table"]
.Select("Caption = 'testUSers'")
.Select(r => r["SourceID"])
.Where(s => s != DBNull.Value)
.Select(s => s.ToString())
.FirstOrDefault();
SourceID = DataSourceId;
//Aqui me aparece el error
SourceID = textBox4.Text;
}
}
return SourceID;
}