Dataset from ObjectDataSource always null?

T

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?
 
P

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.
 
T

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.


Phillip Williams said:
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 said:
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?
 
P

Phillip Williams

Actually at the FormView.DataBinding the label still null but at the
FormView.DataBound it has value.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


timpera2501 said:
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 said:
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 said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top