|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Dataset from ObjectDataSource always null?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? 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? > 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? > > 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? > > >
Other interesting topics
ITemplate - Dynamic ImageButton in BindLabelColumn for DataList
Getting value from child control of formview Embedding CSS with inline code "Protect" or Disable Editing of A Webcontrol SmartNavigation Problem/Bug cache and detailsview, all data controls problem Custom TreeNode for asp.net 2.0 treeview control Multiple onclick Events What is the code for file upload? 2.0 DatagridView and Buttons |
|||||||||||||||||||||||