Home All Groups Group Topic Archive Search About

Dataset from ObjectDataSource always null?

Author
19 Jan 2006 9:19 PM
timpera2501
I've been working on this same problem for 2 full workdays now and I'm about
ready to tear my hair out.  Please!  If anyone knows the answer, please
respond.

Very simply, I have a BusinessLayer bound to an ObjectDataSource called
"ObjectDataSourceEmergencyTTs".  The value passed to
"ObjectDataSourceEmergencyTTs" will always be a single integer.

If that value is "0", I want a formview control called "EmergencyTTs" to NOT
display.

The code I have written to try and accomplish this is located in the
"Page_Onload" event as follows:

*************************
DataSet ds = ObjectDataSourceEmergencyTTs.Select() as DataSet;
        string EMTs =
ds.Tables["EmergencyTTsCount"].Rows[0]["COUNT"].ToString();
        if (String.Equals(EMTs, "0"))
        {
            EmergencyTTs.Visible = false;
        }
        else
        {
            EmergencyTTs.Visible = true;
            OTHER.Text = EMTs;
        }
****************************

The problem is that
"ds.Tables["EmergencyTTsCount"].Rows[0]["COUNT"].ToString();" always returns
null!

However, I know that the value is not null because I have a Label control
within the Formview that displays that value, and it is never null.

I have tried putting this same code in the DataBinding method for both the
ObjectDataSource and the Formview with no change.

Can anyone tell me what I am doing wrong, please?

Author
19 Jan 2006 9:40 PM
Phillip Williams
You should not check for the data that is to be displayed on the FormView
during the Page.Load event handling because the FormView gets populated after
the Page_Load event is fired.

Show quoteHide quote
"timpera2501" wrote:

> I've been working on this same problem for 2 full workdays now and I'm about
> ready to tear my hair out.  Please!  If anyone knows the answer, please
> respond.
>
> Very simply, I have a BusinessLayer bound to an ObjectDataSource called
> "ObjectDataSourceEmergencyTTs".  The value passed to
> "ObjectDataSourceEmergencyTTs" will always be a single integer.
>
> If that value is "0", I want a formview control called "EmergencyTTs" to NOT
> display.
>
> The code I have written to try and accomplish this is located in the
> "Page_Onload" event as follows:
>
> *************************
> DataSet ds = ObjectDataSourceEmergencyTTs.Select() as DataSet;
>         string EMTs =
> ds.Tables["EmergencyTTsCount"].Rows[0]["COUNT"].ToString();
>         if (String.Equals(EMTs, "0"))
>         {
>             EmergencyTTs.Visible = false;
>         }
>         else
>         {
>             EmergencyTTs.Visible = true;
>             OTHER.Text = EMTs;
>         }
> ****************************
>
> The problem is that
> "ds.Tables["EmergencyTTsCount"].Rows[0]["COUNT"].ToString();" always returns
> null!
>
> However, I know that the value is not null because I have a Label control
> within the Formview that displays that value, and it is never null.
>
> I have tried putting this same code in the DataBinding method for both the
> ObjectDataSource and the Formview with no change.
>
> Can anyone tell me what I am doing wrong, please?
>
Are all your drivers up to date? click for free checkup

Author
19 Jan 2006 10:06 PM
timpera2501
Hi Phillip,

It still returns null even when used in the databinding methods for the
formview and objectdatasource controls.

I've tried putting this in nearly every method there is (heh!) while trying
to get it to not be null.


Show quoteHide quote
"Phillip Williams" wrote:

> You should not check for the data that is to be displayed on the FormView
> during the Page.Load event handling because the FormView gets populated after
> the Page_Load event is fired.
>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "timpera2501" wrote:
>
> > I've been working on this same problem for 2 full workdays now and I'm about
> > ready to tear my hair out.  Please!  If anyone knows the answer, please
> > respond.
> >
> > Very simply, I have a BusinessLayer bound to an ObjectDataSource called
> > "ObjectDataSourceEmergencyTTs".  The value passed to
> > "ObjectDataSourceEmergencyTTs" will always be a single integer.
> >
> > If that value is "0", I want a formview control called "EmergencyTTs" to NOT
> > display.
> >
> > The code I have written to try and accomplish this is located in the
> > "Page_Onload" event as follows:
> >
> > *************************
> > DataSet ds = ObjectDataSourceEmergencyTTs.Select() as DataSet;
> >         string EMTs =
> > ds.Tables["EmergencyTTsCount"].Rows[0]["COUNT"].ToString();
> >         if (String.Equals(EMTs, "0"))
> >         {
> >             EmergencyTTs.Visible = false;
> >         }
> >         else
> >         {
> >             EmergencyTTs.Visible = true;
> >             OTHER.Text = EMTs;
> >         }
> > ****************************
> >
> > The problem is that
> > "ds.Tables["EmergencyTTsCount"].Rows[0]["COUNT"].ToString();" always returns
> > null!
> >
> > However, I know that the value is not null because I have a Label control
> > within the Formview that displays that value, and it is never null.
> >
> > I have tried putting this same code in the DataBinding method for both the
> > ObjectDataSource and the Formview with no change.
> >
> > Can anyone tell me what I am doing wrong, please?
> >
Author
20 Jan 2006 12:45 AM
Phillip Williams
Actually at the FormView.DataBinding the label still null but at the 
FormView.DataBound it has value.
Show quoteHide quote
"timpera2501" wrote:

> Hi Phillip,
>
> It still returns null even when used in the databinding methods for the
> formview and objectdatasource controls.
>
> I've tried putting this in nearly every method there is (heh!) while trying
> to get it to not be null.
>
>
> "Phillip Williams" wrote:
>
> > You should not check for the data that is to be displayed on the FormView
> > during the Page.Load event handling because the FormView gets populated after
> > the Page_Load event is fired.
> >
> > --
> > HTH,
> > Phillip Williams
> > http://www.societopia.net
> > http://www.webswapp.com
> >
> >
> > "timpera2501" wrote:
> >
> > > I've been working on this same problem for 2 full workdays now and I'm about
> > > ready to tear my hair out.  Please!  If anyone knows the answer, please
> > > respond.
> > >
> > > Very simply, I have a BusinessLayer bound to an ObjectDataSource called
> > > "ObjectDataSourceEmergencyTTs".  The value passed to
> > > "ObjectDataSourceEmergencyTTs" will always be a single integer.
> > >
> > > If that value is "0", I want a formview control called "EmergencyTTs" to NOT
> > > display.
> > >
> > > The code I have written to try and accomplish this is located in the
> > > "Page_Onload" event as follows:
> > >
> > > *************************
> > > DataSet ds = ObjectDataSourceEmergencyTTs.Select() as DataSet;
> > >         string EMTs =
> > > ds.Tables["EmergencyTTsCount"].Rows[0]["COUNT"].ToString();
> > >         if (String.Equals(EMTs, "0"))
> > >         {
> > >             EmergencyTTs.Visible = false;
> > >         }
> > >         else
> > >         {
> > >             EmergencyTTs.Visible = true;
> > >             OTHER.Text = EMTs;
> > >         }
> > > ****************************
> > >
> > > The problem is that
> > > "ds.Tables["EmergencyTTsCount"].Rows[0]["COUNT"].ToString();" always returns
> > > null!
> > >
> > > However, I know that the value is not null because I have a Label control
> > > within the Formview that displays that value, and it is never null.
> > >
> > > I have tried putting this same code in the DataBinding method for both the
> > > ObjectDataSource and the Formview with no change.
> > >
> > > Can anyone tell me what I am doing wrong, please?
> > >

Bookmark and Share