This code nukes DataBindings

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Max Sandman

    #1

    This code nukes DataBindings

    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.MyTa ble[0].stringfield1.L ength == 0)
    check1.Checked = true;
    else
    check1.Checked = false;
    }

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


    sandman

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
  • Frank Oquendo

    #2
    Re: This code nukes DataBindings

    Max Sandman wrote:[color=blue]
    > Does anybody know what's wrong with it?[/color]

    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]["stringfiel d1"].ToString().Len gth == 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.




    Comment

    • Chris Capel

      #3
      Re: This code nukes DataBindings

      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" <franko@acadx.c om> wrote in message
      news:un1WvW$cDH A.1280@tk2msftn gp13.phx.gbl...[color=blue]
      > Max Sandman wrote:[color=green]
      > > Does anybody know what's wrong with it?[/color]
      >
      > 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]["stringfiel d1"].ToString().Len gth == 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
      >
      >[/color]


      Comment

      Working...