This code nukes DataBindings

  • Thread starter Thread starter Max Sandman
  • Start date Start date
M

Max Sandman

When I had this code commented out, everything ran fine. But as soon as
I uncommented it, it nuked the databindings for every field bound to the
dataset. Does anybody know what's wrong with it?

try
{
if (dataSet11.MyTable[0].stringfield1.Length == 0)
check1.Checked = true;
else
check1.Checked = false;
}

catch (StrongTypingException ex)
{
// fld1 is null
check1.Checked = true;
}


sandman
 
Max said:
Does anybody know what's wrong with it?

Are you trying to check the value of a particular field for a given row
within the table? If so, your code should look more like this:

if (dataSet.Tables[0].Rows[0]["stringfield1"].ToString().Length == 0)

As far as I know, DataSets don't have a MyTable property nor do
DataTables have a stringfield1 property.
 
When you use the designer to create a strongly typed dataset then the
tables, columns, and row fields are accessible using properties, instead of
indexed Table and Row collections.

Chris

Frank Oquendo said:
Max said:
Does anybody know what's wrong with it?

Are you trying to check the value of a particular field for a given row
within the table? If so, your code should look more like this:

if (dataSet.Tables[0].Rows[0]["stringfield1"].ToString().Length == 0)

As far as I know, DataSets don't have a MyTable property nor do
DataTables have a stringfield1 property.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
 
Back
Top