Thursday, March 29, 2012

missing pictures and stylesheet-information

you you using relative or absolute pathing for the images? is "allow parent
paths" turned on in the IIS config? Most likely it's a config issue of that
type. Go through the IIS settings tab by tab.

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com

"Patrick Rogalski" <anonymous@dotnet.itags.org.discussions.microsoft.com> wrote in message
news:68C48ADC-276A-438E-903E-E7AEE77AD6ED@dotnet.itags.org.microsoft.com...
> Hi,
> I have the following problem in one customer-environment: the pages in the
browser are not displayed properly. The pictures and styles from the
stylesheet are missing (I can only see the placeholder and the colors are
missing). If I have a look to the sources of the page in the browser (IE6),
the content of all src-tags are ok. If I type the adress of the picture
direct into the adressline, the browser shows the picture. The pictures and
stylesheets are available, the page has all required src-tags but they are
not displayed. I have a few installations of this application, but only this
one works not properly.
> Any ideas what it can be ? Would be very great... Thanks Patrick :o)Hi

yes I use relative pathing. I've deactivated this option on my own system, but it still works properly. I'll try it on the customers system

Thanks Patrick

Missing QueryStirng?

I'm integrating my application with a Flash front-end and when the Flash
requests my login page with ?login=x&password=y queryString appeded to the
URL, this information get's lost.
If I put the entire URL in my browser, everything goes fine, but, when I
call it from Flash the query string is missing and I get to my login page.
Is there any issue in starting calling a ASP.Net app from another site with
a queryString appended to the loginForm's URL? (really getting crazy!!!)
Thanks for any help,
Regards,
Victor ReboucasWe can't really give you an answer without you posting the relevant code.
However, you do not want to be passing the password in the query string -
not secure at all.
"VR" <vcreb@.hotmail.com> wrote in message
news:%23IHF0vGaFHA.3784@.TK2MSFTNGP12.phx.gbl...
> I'm integrating my application with a Flash front-end and when the Flash
> requests my login page with ?login=x&password=y queryString appeded to the
> URL, this information get's lost.
> If I put the entire URL in my browser, everything goes fine, but, when I
> call it from Flash the query string is missing and I get to my login page.
> Is there any issue in starting calling a ASP.Net app from another site
> with a queryString appended to the loginForm's URL? (really getting
> crazy!!!)
>
> Thanks for any help,
> Regards,
> Victor Reboucas
>
Really sorry about this post...
The guy was sending my the values using POST, but told me he was using
GET...
sorry,
Victor Reboucas
"Marina" <someone@.nospam.com> wrote in message
news:epv$5xGaFHA.616@.TK2MSFTNGP12.phx.gbl...
> We can't really give you an answer without you posting the relevant code.
> However, you do not want to be passing the password in the query string -
> not secure at all.
> "VR" <vcreb@.hotmail.com> wrote in message
> news:%23IHF0vGaFHA.3784@.TK2MSFTNGP12.phx.gbl...
>

Missing QueryStirng?

I'm integrating my application with a Flash front-end and when the Flash
requests my login page with ?login=x&password=y queryString appeded to the
URL, this information get's lost.

If I put the entire URL in my browser, everything goes fine, but, when I
call it from Flash the query string is missing and I get to my login page.

Is there any issue in starting calling a ASP.Net app from another site with
a queryString appended to the loginForm's URL? (really getting crazy!!!)

Thanks for any help,
Regards,
Victor ReboucasWe can't really give you an answer without you posting the relevant code.

However, you do not want to be passing the password in the query string -
not secure at all.

"VR" <vcreb@.hotmail.com> wrote in message
news:%23IHF0vGaFHA.3784@.TK2MSFTNGP12.phx.gbl...
> I'm integrating my application with a Flash front-end and when the Flash
> requests my login page with ?login=x&password=y queryString appeded to the
> URL, this information get's lost.
> If I put the entire URL in my browser, everything goes fine, but, when I
> call it from Flash the query string is missing and I get to my login page.
> Is there any issue in starting calling a ASP.Net app from another site
> with a queryString appended to the loginForm's URL? (really getting
> crazy!!!)
>
> Thanks for any help,
> Regards,
> Victor Reboucas
Really sorry about this post...

The guy was sending my the values using POST, but told me he was using
GET...

sorry,
Victor Reboucas

"Marina" <someone@.nospam.com> wrote in message
news:epv$5xGaFHA.616@.TK2MSFTNGP12.phx.gbl...
> We can't really give you an answer without you posting the relevant code.
> However, you do not want to be passing the password in the query string -
> not secure at all.
> "VR" <vcreb@.hotmail.com> wrote in message
> news:%23IHF0vGaFHA.3784@.TK2MSFTNGP12.phx.gbl...
>> I'm integrating my application with a Flash front-end and when the Flash
>> requests my login page with ?login=x&password=y queryString appeded to
>> the URL, this information get's lost.
>>
>> If I put the entire URL in my browser, everything goes fine, but, when I
>> call it from Flash the query string is missing and I get to my login
>> page.
>>
>> Is there any issue in starting calling a ASP.Net app from another site
>> with a queryString appended to the loginForm's URL? (really getting
>> crazy!!!)
>>
>>
>> Thanks for any help,
>> Regards,
>> Victor Reboucas
>>

Missing Referring URL in log files

We have a strange situation where some of the referring URL's are
missing from our log files. This is on .NET application on IIS 6.0.
Here is what is happening:

Page a.aspx has a form that POST's to a.aspx. If there are errors with
the form information, then a.aspx is displayed with an error message to
the user.

If all the information is correct then it is redirected
(response.redirect) - GET to page b.aspx. In this GET to b.aspx (and
only in the GET by redirect), the referring URL is not being saved in
IIS log files.

Does anyone have any ideas on how we can fix this?

Thanksit has nothing to do with .net the browser is responsible for sending
the referring url. you browser is not sending one a redirect.

note: some proxy server will always strip the referring url for security
reasons.

-- bruce (sqlwork.com)

paladin wrote:

Quote:

Originally Posted by

We have a strange situation where some of the referring URL's are
missing from our log files. This is on .NET application on IIS 6.0.
Here is what is happening:
>
Page a.aspx has a form that POST's to a.aspx. If there are errors with
the form information, then a.aspx is displayed with an error message to
the user.
>
If all the information is correct then it is redirected
(response.redirect) - GET to page b.aspx. In this GET to b.aspx (and
only in the GET by redirect), the referring URL is not being saved in
IIS log files.
>
Does anyone have any ideas on how we can fix this?
>
Thanks
>


I managed to narrow it down to the Mozilla version in the browser. v4.0
does not send the referrer while v5.0 does. The strange thing is that I
have IE7 with Mozilla 4.0 (does not send the referrer) while my boss
has IE6 with Mozilla 5.0 (his send the referrer).

Do you know if there is a way to programatically add the referrer in
the case of v4.0 so that it shows up in the IIS logs.

Another thing we are seeing is that the .NET redirects the user from
mydomain.com/folder/file.aspx to
mydomain.com/(S(sessionID))folder/file.aspx. This (S(sessionID)) shows
up in the referring URL in the logs but not in the requested file path
column. Any ideas?

thanks
Alon

bruce barker wrote:

Quote:

Originally Posted by

it has nothing to do with .net the browser is responsible for sending
the referring url. you browser is not sending one a redirect.
>
note: some proxy server will always strip the referring url for security
reasons.
>
-- bruce (sqlwork.com)
>
paladin wrote:

Quote:

Originally Posted by

We have a strange situation where some of the referring URL's are
missing from our log files. This is on .NET application on IIS 6.0.
Here is what is happening:

Page a.aspx has a form that POST's to a.aspx. If there are errors with
the form information, then a.aspx is displayed with an error message to
the user.

If all the information is correct then it is redirected
(response.redirect) - GET to page b.aspx. In this GET to b.aspx (and
only in the GET by redirect), the referring URL is not being saved in
IIS log files.

Does anyone have any ideas on how we can fix this?

Thanks

Missing Referring URL in log files

We have a strange situation where some of the referring URL's are
missing from our log files. This is on .NET application on IIS 6.0.
Here is what is happening:
Page a.aspx has a form that POST's to a.aspx. If there are errors with
the form information, then a.aspx is displayed with an error message to
the user.
If all the information is correct then it is redirected
(response.redirect) - GET to page b.aspx. In this GET to b.aspx (and
only in the GET by redirect), the referring URL is not being saved in
IIS log files.
Does anyone have any ideas on how we can fix this?
Thanksit has nothing to do with .net the browser is responsible for sending
the referring url. you browser is not sending one a redirect.
note: some proxy server will always strip the referring url for security
reasons.
-- bruce (sqlwork.com)
paladin wrote:
> We have a strange situation where some of the referring URL's are
> missing from our log files. This is on .NET application on IIS 6.0.
> Here is what is happening:
> Page a.aspx has a form that POST's to a.aspx. If there are errors with
> the form information, then a.aspx is displayed with an error message to
> the user.
> If all the information is correct then it is redirected
> (response.redirect) - GET to page b.aspx. In this GET to b.aspx (and
> only in the GET by redirect), the referring URL is not being saved in
> IIS log files.
> Does anyone have any ideas on how we can fix this?
> Thanks
>
I managed to narrow it down to the Mozilla version in the browser. v4.0
does not send the referrer while v5.0 does. The strange thing is that I
have IE7 with Mozilla 4.0 (does not send the referrer) while my boss
has IE6 with Mozilla 5.0 (his send the referrer).
Do you know if there is a way to programatically add the referrer in
the case of v4.0 so that it shows up in the IIS logs.
Another thing we are seeing is that the .NET redirects the user from
mydomain.com/folder/file.aspx to
mydomain.com/(S(sessionID))folder/file.aspx. This (S(sessionID)) shows
up in the referring URL in the logs but not in the requested file path
column. Any ideas?
thanks
Alon
bruce barker wrote:
> it has nothing to do with .net the browser is responsible for sending
> the referring url. you browser is not sending one a redirect.
> note: some proxy server will always strip the referring url for security
> reasons.
> -- bruce (sqlwork.com)
> paladin wrote:

Missing required parameter error

I've distilled this down into the simplest possible code fragment and
this still doesn't make any sense. I'm trying to run a select query on
an access database, and the query has NO parameters. And yet, I'm
still getting a "No value given for one or more required parameters"
error. What gives?

Here's my code. I put it in a Form_Load subroutine of a blank .aspx
page so that nothing else external would affect it. (And yes, the
Access database is meant to have a user name and password.)

Protected Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Dim myConnection As System.Data.OleDb.OleDbConnection
Dim connStr As String
connStr = String.Format("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=" & Server.MapPath(MyGlobals.ACCESS_DB) & "; " & _
"Persist Security Info=True; Jet
OLEDB:Engine Type=5; Jet OLEDB:System Database=" & _
MyGlobals.ACCESS_SYSTEM_MDW & "; User
ID=" & _
"XXXXX" & "; Password=" & _
"XXXXX")
myConnection = New System.Data.OleDb.OleDbConnection(connStr)
Dim mySelectQuery As String
Dim myCommand As New System.Data.OleDb.OleDbCommand()

mySelectQuery = "SELECT EmployeeID, LastName, FirstName,
EmpFileNumber " & _
"FROM employees"
myCommand = New System.Data.OleDb.OleDbCommand(mySelectQuery,
myConnection)

myConnection.Open()

Dim myReader As System.Data.OleDb.OleDbDataReader
myReader =
myCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
<-- error happens here

myConnection = Nothing
End Sub

Any ideas, anyone?

Damonadd
myCommand.CommandType = CommandType.Text
before the execute.

Regards,

Trevor Benedict R
MCSD

"Damon" <kowa@.redshift.com> wrote in message
news:1140469727.000825.71270@.g43g2000cwa.googlegro ups.com...
> I've distilled this down into the simplest possible code fragment and
> this still doesn't make any sense. I'm trying to run a select query on
> an access database, and the query has NO parameters. And yet, I'm
> still getting a "No value given for one or more required parameters"
> error. What gives?
> Here's my code. I put it in a Form_Load subroutine of a blank .aspx
> page so that nothing else external would affect it. (And yes, the
> Access database is meant to have a user name and password.)
> Protected Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs)
> Dim myConnection As System.Data.OleDb.OleDbConnection
> Dim connStr As String
> connStr = String.Format("Provider=Microsoft.Jet.OLEDB.4.0; Data
> Source=" & Server.MapPath(MyGlobals.ACCESS_DB) & "; " & _
> "Persist Security Info=True; Jet
> OLEDB:Engine Type=5; Jet OLEDB:System Database=" & _
> MyGlobals.ACCESS_SYSTEM_MDW & "; User
> ID=" & _
> "XXXXX" & "; Password=" & _
> "XXXXX")
> myConnection = New System.Data.OleDb.OleDbConnection(connStr)
> Dim mySelectQuery As String
> Dim myCommand As New System.Data.OleDb.OleDbCommand()
> mySelectQuery = "SELECT EmployeeID, LastName, FirstName,
> EmpFileNumber " & _
> "FROM employees"
> myCommand = New System.Data.OleDb.OleDbCommand(mySelectQuery,
> myConnection)
> myConnection.Open()
> Dim myReader As System.Data.OleDb.OleDbDataReader
> myReader =
> myCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
> <-- error happens here
> myConnection = Nothing
> End Sub
> Any ideas, anyone?
> Damon

Missing Rows in a DataBind()

Hey all,
Have a strange one here, and being still fairly new to .NET isn't helping me
understand it.
I am having a problem where a DataReader doesn't return all the rows when I
try to use a method from a separate class file that returns a DataReader,
where when I code the DataReader in the .aspx file it does. Below are the
details and code of what I am runnign into. I appreciate any help/insight
you can provide.
I am working on a fairly simple app that allow a user to add/update/delete
meeting minutes and agendas. I have a database (SQL Server 2000) storing
some simple info, and a directory the Mins/Agnd PDF file is uploaded to. I
created a little web user control that uses a DataGrid and DropDown listbox.
I bind each one separately, and use stored procedures to query the DB.
Originally I did the following function, called in the page's OnLoad method
only if Page.IsPostback was false:
Private Sub BindYearDropDown()
Dim con As New
SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
Dim cmd As SqlCommand = New SqlCommand("spAgendas_GetAllAgendaYears", con)
lstAgendas.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection)
lstAgendas.DataTextField = "Year"
lstAgendas.DataValueField = "Year"
lstAgendas.DataBind()
End Sub
(My S-Proc is a basic "SELECT DISTINCT vYear FROM MyTable ORDER BY vYear
DESC")
All this does is populate a DropDown list with the distinct years in the DB
(2000 through 2004 in my case). I decided to use a DataReader beacuase I am
not doing two-way communication, and also the DR runs much faster due to
lesser overhead requirements. Well, as I was building this app, I started
to have more and more methods needing to talk to the DB. Well, I wanted to
create a single function that I could just call and it would return a set of
records that I could rummage through or bind to data sources. This way I
could just reuse the same method over and over, and if anything in my DB
connection changed, I didn't have to worry about finding all the location
throughout the app and missing some change.
So, I created the following function in a "business objects" class file:
Public Function GetADataReader(ByVal sSQL As String) As SqlDataReader
Dim con As New
SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
Dim cmd As SqlCommand = New SqlCommand(sSQL, con)
Dim dr As SqlDataReader
Try
con.Open()
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
dr.Read()
Return dr
Catch ex As Exception
Throw
End Try
End Function
And then I altered my binding method back in my control to the following
(BoardBO is my "business objects" class file):
Private Sub BindYearDropDown()
lstAgendas.DataSource =
BoardBO.GetADataReader("spAgendas_GetAllAgendaYears")
lstAgendas.DataTextField = "Year"
lstAgendas.DataValueField = "Year"
lstAgendas.DataBind()
End Sub
And now we get to my question/problem. When I did it the first way, I got
all five years (2004 through 2000). Yet when I do it the second way, I only
get 4 years (2003 through 2000). I debugged the code by adding a breakpoint
on the GetADataReader method and stepping through it one line at a time.
After the dr.Read() call, in the command window I typed "?dr(0)" and it gave
me "2004", yet once the DataBind() method of the BindYearDropDown method is
called, "2004" is nowhere to be seen. Huh? I don't get this.
Wondering if it was something about a "remote" DataReader method, I also
created a "remote" DataSet method to do the exact same thing, but using a
DataSet object vice a SQLDataReader. That function is :
Public Function GetADataSet(ByVal sSQL As String) As DataSet
Dim con As String =
ConfigurationSettings.AppSettings("SQLServer_BOS")
Dim da As New SqlDataAdapter(sSQL, con)
Dim ds As New DataSet
Try
da.Fill(ds)
Return ds
Catch ex As Exception
Throw
End Try
End Function
And then I changed my dropdown list data bind method to:
Private Sub BindYearDropDown()
lstAgendas.DataSource =
BoardBO.GetADataSet("spAgendas_GetAllAgendaYears").Tables(0)
lstAgendas.DataTextField = "Year"
lstAgendas.DataValueField = "Year"
lstAgendas.DataBind()
End Sub
Low and behold, I got all five years once again (2004 - 2000)!
What is it about doing this with a DataSet instead of a DataReader that
gives me all my data? Why is the DataReader method loosing the first row in
the returned records? I don't understand this.
If you can help me to understand what is happening, I sure would appreciate
it. Thanks!!
-- AndrewYou call .Read before you return the erader - which advances the reader to
the first row. I assume your problem is always missing the first row from
the result set? Well, this is why.
"Andrew" <AndrewR2k1@.hotmail.com> wrote in message
news:eKv185lHEHA.828@.TK2MSFTNGP12.phx.gbl...
> Hey all,
> Have a strange one here, and being still fairly new to .NET isn't helping
me
> understand it.
> I am having a problem where a DataReader doesn't return all the rows when
I
> try to use a method from a separate class file that returns a DataReader,
> where when I code the DataReader in the .aspx file it does. Below are the
> details and code of what I am runnign into. I appreciate any help/insight
> you can provide.
> I am working on a fairly simple app that allow a user to add/update/delete
> meeting minutes and agendas. I have a database (SQL Server 2000) storing
> some simple info, and a directory the Mins/Agnd PDF file is uploaded to.
I
> created a little web user control that uses a DataGrid and DropDown
listbox.
> I bind each one separately, and use stored procedures to query the DB.
> Originally I did the following function, called in the page's OnLoad
method
> only if Page.IsPostback was false:
> Private Sub BindYearDropDown()
> Dim con As New
> SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
> Dim cmd As SqlCommand = New SqlCommand("spAgendas_GetAllAgendaYears",
con)
> lstAgendas.DataSource =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
> lstAgendas.DataTextField = "Year"
> lstAgendas.DataValueField = "Year"
> lstAgendas.DataBind()
> End Sub
> (My S-Proc is a basic "SELECT DISTINCT vYear FROM MyTable ORDER BY vYear
> DESC")
> All this does is populate a DropDown list with the distinct years in the
DB
> (2000 through 2004 in my case). I decided to use a DataReader beacuase I
am
> not doing two-way communication, and also the DR runs much faster due to
> lesser overhead requirements. Well, as I was building this app, I started
> to have more and more methods needing to talk to the DB. Well, I wanted
to
> create a single function that I could just call and it would return a set
of
> records that I could rummage through or bind to data sources. This way I
> could just reuse the same method over and over, and if anything in my DB
> connection changed, I didn't have to worry about finding all the location
> throughout the app and missing some change.
> So, I created the following function in a "business objects" class file:
> Public Function GetADataReader(ByVal sSQL As String) As SqlDataReader
> Dim con As New
> SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
> Dim cmd As SqlCommand = New SqlCommand(sSQL, con)
> Dim dr As SqlDataReader
> Try
> con.Open()
> dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
> dr.Read()
> Return dr
> Catch ex As Exception
> Throw
> End Try
> End Function
> And then I altered my binding method back in my control to the following
> (BoardBO is my "business objects" class file):
> Private Sub BindYearDropDown()
> lstAgendas.DataSource =
> BoardBO.GetADataReader("spAgendas_GetAllAgendaYears")
> lstAgendas.DataTextField = "Year"
> lstAgendas.DataValueField = "Year"
> lstAgendas.DataBind()
> End Sub
> And now we get to my question/problem. When I did it the first way, I got
> all five years (2004 through 2000). Yet when I do it the second way, I
only
> get 4 years (2003 through 2000). I debugged the code by adding a
breakpoint
> on the GetADataReader method and stepping through it one line at a time.
> After the dr.Read() call, in the command window I typed "?dr(0)" and it
gave
> me "2004", yet once the DataBind() method of the BindYearDropDown method
is
> called, "2004" is nowhere to be seen. Huh? I don't get this.
> Wondering if it was something about a "remote" DataReader method, I also
> created a "remote" DataSet method to do the exact same thing, but using a
> DataSet object vice a SQLDataReader. That function is :
> Public Function GetADataSet(ByVal sSQL As String) As DataSet
> Dim con As String =
> ConfigurationSettings.AppSettings("SQLServer_BOS")
> Dim da As New SqlDataAdapter(sSQL, con)
> Dim ds As New DataSet
> Try
> da.Fill(ds)
> Return ds
> Catch ex As Exception
> Throw
> End Try
> End Function
> And then I changed my dropdown list data bind method to:
> Private Sub BindYearDropDown()
> lstAgendas.DataSource =
> BoardBO.GetADataSet("spAgendas_GetAllAgendaYears").Tables(0)
> lstAgendas.DataTextField = "Year"
> lstAgendas.DataValueField = "Year"
> lstAgendas.DataBind()
> End Sub
> Low and behold, I got all five years once again (2004 - 2000)!
> What is it about doing this with a DataSet instead of a DataReader that
> gives me all my data? Why is the DataReader method loosing the first row
in
> the returned records? I don't understand this.
> If you can help me to understand what is happening, I sure would
appreciate
> it. Thanks!!
> -- Andrew
>
Damn, I took all that time and effort to write up the message and you go an
solve it in three lines. I guess .Net is more productive. :) Thanks for
the help, it was right on the money!
-- Andrew
"Marina" <someone@.nospam.com> wrote in message
news:uxq6d$lHEHA.1220@.tk2msftngp13.phx.gbl...
> You call .Read before you return the erader - which advances the reader to
> the first row. I assume your problem is always missing the first row from
> the result set? Well, this is why.
> "Andrew" <AndrewR2k1@.hotmail.com> wrote in message
> news:eKv185lHEHA.828@.TK2MSFTNGP12.phx.gbl...
helping
> me
when
> I
DataReader,
the
help/insight
add/update/delete
storing
> I
> listbox.
> method
> con)
> cmd.ExecuteReader(CommandBehavior.CloseConnection)
> DB
I
> am
started
> to
set
> of
I
location
SqlDataReader
got
> only
> breakpoint
> gave
> is
a
row
> in
> appreciate
>

Missing rows after exporting to excel...

Hi,

Anyone can help me? thks...

Justin

Hi Justin,

justin00:

Anyone can help me? thks...

the community members around here are very willing to help out but without seeing some actual, relevant, code that you already created it's going to be somewhat difficult.

Grz, Kris.


Thanks for the fast reply..Kris.

This is how my code goes for exporting, pnlCC is my panel name:

Response.Clear()
Response.Buffer =

True
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Response.ContentEncoding = System.Text.Encoding.UTF7
Response.AddHeader("Content-Disposition", "attachment;filename=TemporaryFile.xls")
Me.EnableViewState =False
Dim oStringWriterAs System.IO.StringWriter =New System.IO.StringWriter()
Dim oHtmlTextWriterAs System.Web.UI.HtmlTextWriter =New System.Web.UI.HtmlTextWriter(oStringWriter)pnlCC.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.End()

I have no problem exporting to excel, but last few rows seem to be cut off after export.
Thanks...hope someone have some ideas on this problem.

Missing Rows in a DataBind()

Hey all,

Have a strange one here, and being still fairly new to .NET isn't helping me
understand it.

I am having a problem where a DataReader doesn't return all the rows when I
try to use a method from a separate class file that returns a DataReader,
where when I code the DataReader in the .aspx file it does. Below are the
details and code of what I am runnign into. I appreciate any help/insight
you can provide.

I am working on a fairly simple app that allow a user to add/update/delete
meeting minutes and agendas. I have a database (SQL Server 2000) storing
some simple info, and a directory the Mins/Agnd PDF file is uploaded to. I
created a little web user control that uses a DataGrid and DropDown listbox.
I bind each one separately, and use stored procedures to query the DB.

Originally I did the following function, called in the page's OnLoad method
only if Page.IsPostback was false:

Private Sub BindYearDropDown()
Dim con As New
SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
Dim cmd As SqlCommand = New SqlCommand("spAgendas_GetAllAgendaYears", con)
lstAgendas.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection)
lstAgendas.DataTextField = "Year"
lstAgendas.DataValueField = "Year"
lstAgendas.DataBind()
End Sub

(My S-Proc is a basic "SELECT DISTINCT vYear FROM MyTable ORDER BY vYear
DESC")

All this does is populate a DropDown list with the distinct years in the DB
(2000 through 2004 in my case). I decided to use a DataReader beacuase I am
not doing two-way communication, and also the DR runs much faster due to
lesser overhead requirements. Well, as I was building this app, I started
to have more and more methods needing to talk to the DB. Well, I wanted to
create a single function that I could just call and it would return a set of
records that I could rummage through or bind to data sources. This way I
could just reuse the same method over and over, and if anything in my DB
connection changed, I didn't have to worry about finding all the location
throughout the app and missing some change.

So, I created the following function in a "business objects" class file:

Public Function GetADataReader(ByVal sSQL As String) As SqlDataReader
Dim con As New
SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
Dim cmd As SqlCommand = New SqlCommand(sSQL, con)
Dim dr As SqlDataReader
Try
con.Open()
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
dr.Read()
Return dr
Catch ex As Exception
Throw
End Try
End Function

And then I altered my binding method back in my control to the following
(BoardBO is my "business objects" class file):

Private Sub BindYearDropDown()

lstAgendas.DataSource =
BoardBO.GetADataReader("spAgendas_GetAllAgendaYears")
lstAgendas.DataTextField = "Year"
lstAgendas.DataValueField = "Year"
lstAgendas.DataBind()

End Sub

And now we get to my question/problem. When I did it the first way, I got
all five years (2004 through 2000). Yet when I do it the second way, I only
get 4 years (2003 through 2000). I debugged the code by adding a breakpoint
on the GetADataReader method and stepping through it one line at a time.
After the dr.Read() call, in the command window I typed "?dr(0)" and it gave
me "2004", yet once the DataBind() method of the BindYearDropDown method is
called, "2004" is nowhere to be seen. Huh? I don't get this.

Wondering if it was something about a "remote" DataReader method, I also
created a "remote" DataSet method to do the exact same thing, but using a
DataSet object vice a SQLDataReader. That function is :

Public Function GetADataSet(ByVal sSQL As String) As DataSet
Dim con As String =
ConfigurationSettings.AppSettings("SQLServer_BOS")
Dim da As New SqlDataAdapter(sSQL, con)
Dim ds As New DataSet
Try
da.Fill(ds)
Return ds
Catch ex As Exception
Throw
End Try
End Function

And then I changed my dropdown list data bind method to:

Private Sub BindYearDropDown()

lstAgendas.DataSource =
BoardBO.GetADataSet("spAgendas_GetAllAgendaYears").Tables(0)
lstAgendas.DataTextField = "Year"
lstAgendas.DataValueField = "Year"
lstAgendas.DataBind()

End Sub

Low and behold, I got all five years once again (2004 - 2000)!

What is it about doing this with a DataSet instead of a DataReader that
gives me all my data? Why is the DataReader method loosing the first row in
the returned records? I don't understand this.

If you can help me to understand what is happening, I sure would appreciate
it. Thanks!!

-- AndrewYou call .Read before you return the erader - which advances the reader to
the first row. I assume your problem is always missing the first row from
the result set? Well, this is why.

"Andrew" <AndrewR2k1@.hotmail.com> wrote in message
news:eKv185lHEHA.828@.TK2MSFTNGP12.phx.gbl...
> Hey all,
> Have a strange one here, and being still fairly new to .NET isn't helping
me
> understand it.
> I am having a problem where a DataReader doesn't return all the rows when
I
> try to use a method from a separate class file that returns a DataReader,
> where when I code the DataReader in the .aspx file it does. Below are the
> details and code of what I am runnign into. I appreciate any help/insight
> you can provide.
> I am working on a fairly simple app that allow a user to add/update/delete
> meeting minutes and agendas. I have a database (SQL Server 2000) storing
> some simple info, and a directory the Mins/Agnd PDF file is uploaded to.
I
> created a little web user control that uses a DataGrid and DropDown
listbox.
> I bind each one separately, and use stored procedures to query the DB.
> Originally I did the following function, called in the page's OnLoad
method
> only if Page.IsPostback was false:
> Private Sub BindYearDropDown()
> Dim con As New
> SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
> Dim cmd As SqlCommand = New SqlCommand("spAgendas_GetAllAgendaYears",
con)
> lstAgendas.DataSource =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
> lstAgendas.DataTextField = "Year"
> lstAgendas.DataValueField = "Year"
> lstAgendas.DataBind()
> End Sub
> (My S-Proc is a basic "SELECT DISTINCT vYear FROM MyTable ORDER BY vYear
> DESC")
> All this does is populate a DropDown list with the distinct years in the
DB
> (2000 through 2004 in my case). I decided to use a DataReader beacuase I
am
> not doing two-way communication, and also the DR runs much faster due to
> lesser overhead requirements. Well, as I was building this app, I started
> to have more and more methods needing to talk to the DB. Well, I wanted
to
> create a single function that I could just call and it would return a set
of
> records that I could rummage through or bind to data sources. This way I
> could just reuse the same method over and over, and if anything in my DB
> connection changed, I didn't have to worry about finding all the location
> throughout the app and missing some change.
> So, I created the following function in a "business objects" class file:
> Public Function GetADataReader(ByVal sSQL As String) As SqlDataReader
> Dim con As New
> SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
> Dim cmd As SqlCommand = New SqlCommand(sSQL, con)
> Dim dr As SqlDataReader
> Try
> con.Open()
> dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
> dr.Read()
> Return dr
> Catch ex As Exception
> Throw
> End Try
> End Function
> And then I altered my binding method back in my control to the following
> (BoardBO is my "business objects" class file):
> Private Sub BindYearDropDown()
> lstAgendas.DataSource =
> BoardBO.GetADataReader("spAgendas_GetAllAgendaYears")
> lstAgendas.DataTextField = "Year"
> lstAgendas.DataValueField = "Year"
> lstAgendas.DataBind()
> End Sub
> And now we get to my question/problem. When I did it the first way, I got
> all five years (2004 through 2000). Yet when I do it the second way, I
only
> get 4 years (2003 through 2000). I debugged the code by adding a
breakpoint
> on the GetADataReader method and stepping through it one line at a time.
> After the dr.Read() call, in the command window I typed "?dr(0)" and it
gave
> me "2004", yet once the DataBind() method of the BindYearDropDown method
is
> called, "2004" is nowhere to be seen. Huh? I don't get this.
> Wondering if it was something about a "remote" DataReader method, I also
> created a "remote" DataSet method to do the exact same thing, but using a
> DataSet object vice a SQLDataReader. That function is :
> Public Function GetADataSet(ByVal sSQL As String) As DataSet
> Dim con As String =
> ConfigurationSettings.AppSettings("SQLServer_BOS")
> Dim da As New SqlDataAdapter(sSQL, con)
> Dim ds As New DataSet
> Try
> da.Fill(ds)
> Return ds
> Catch ex As Exception
> Throw
> End Try
> End Function
> And then I changed my dropdown list data bind method to:
> Private Sub BindYearDropDown()
> lstAgendas.DataSource =
> BoardBO.GetADataSet("spAgendas_GetAllAgendaYears").Tables(0)
> lstAgendas.DataTextField = "Year"
> lstAgendas.DataValueField = "Year"
> lstAgendas.DataBind()
> End Sub
> Low and behold, I got all five years once again (2004 - 2000)!
> What is it about doing this with a DataSet instead of a DataReader that
> gives me all my data? Why is the DataReader method loosing the first row
in
> the returned records? I don't understand this.
> If you can help me to understand what is happening, I sure would
appreciate
> it. Thanks!!
> -- Andrew
You call .Read before you return the erader - which advances the reader to
the first row. I assume your problem is always missing the first row from
the result set? Well, this is why.

"Andrew" <AndrewR2k1@.hotmail.com> wrote in message
news:eKv185lHEHA.828@.TK2MSFTNGP12.phx.gbl...
> Hey all,
> Have a strange one here, and being still fairly new to .NET isn't helping
me
> understand it.
> I am having a problem where a DataReader doesn't return all the rows when
I
> try to use a method from a separate class file that returns a DataReader,
> where when I code the DataReader in the .aspx file it does. Below are the
> details and code of what I am runnign into. I appreciate any help/insight
> you can provide.
> I am working on a fairly simple app that allow a user to add/update/delete
> meeting minutes and agendas. I have a database (SQL Server 2000) storing
> some simple info, and a directory the Mins/Agnd PDF file is uploaded to.
I
> created a little web user control that uses a DataGrid and DropDown
listbox.
> I bind each one separately, and use stored procedures to query the DB.
> Originally I did the following function, called in the page's OnLoad
method
> only if Page.IsPostback was false:
> Private Sub BindYearDropDown()
> Dim con As New
> SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
> Dim cmd As SqlCommand = New SqlCommand("spAgendas_GetAllAgendaYears",
con)
> lstAgendas.DataSource =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
> lstAgendas.DataTextField = "Year"
> lstAgendas.DataValueField = "Year"
> lstAgendas.DataBind()
> End Sub
> (My S-Proc is a basic "SELECT DISTINCT vYear FROM MyTable ORDER BY vYear
> DESC")
> All this does is populate a DropDown list with the distinct years in the
DB
> (2000 through 2004 in my case). I decided to use a DataReader beacuase I
am
> not doing two-way communication, and also the DR runs much faster due to
> lesser overhead requirements. Well, as I was building this app, I started
> to have more and more methods needing to talk to the DB. Well, I wanted
to
> create a single function that I could just call and it would return a set
of
> records that I could rummage through or bind to data sources. This way I
> could just reuse the same method over and over, and if anything in my DB
> connection changed, I didn't have to worry about finding all the location
> throughout the app and missing some change.
> So, I created the following function in a "business objects" class file:
> Public Function GetADataReader(ByVal sSQL As String) As SqlDataReader
> Dim con As New
> SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
> Dim cmd As SqlCommand = New SqlCommand(sSQL, con)
> Dim dr As SqlDataReader
> Try
> con.Open()
> dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
> dr.Read()
> Return dr
> Catch ex As Exception
> Throw
> End Try
> End Function
> And then I altered my binding method back in my control to the following
> (BoardBO is my "business objects" class file):
> Private Sub BindYearDropDown()
> lstAgendas.DataSource =
> BoardBO.GetADataReader("spAgendas_GetAllAgendaYears")
> lstAgendas.DataTextField = "Year"
> lstAgendas.DataValueField = "Year"
> lstAgendas.DataBind()
> End Sub
> And now we get to my question/problem. When I did it the first way, I got
> all five years (2004 through 2000). Yet when I do it the second way, I
only
> get 4 years (2003 through 2000). I debugged the code by adding a
breakpoint
> on the GetADataReader method and stepping through it one line at a time.
> After the dr.Read() call, in the command window I typed "?dr(0)" and it
gave
> me "2004", yet once the DataBind() method of the BindYearDropDown method
is
> called, "2004" is nowhere to be seen. Huh? I don't get this.
> Wondering if it was something about a "remote" DataReader method, I also
> created a "remote" DataSet method to do the exact same thing, but using a
> DataSet object vice a SQLDataReader. That function is :
> Public Function GetADataSet(ByVal sSQL As String) As DataSet
> Dim con As String =
> ConfigurationSettings.AppSettings("SQLServer_BOS")
> Dim da As New SqlDataAdapter(sSQL, con)
> Dim ds As New DataSet
> Try
> da.Fill(ds)
> Return ds
> Catch ex As Exception
> Throw
> End Try
> End Function
> And then I changed my dropdown list data bind method to:
> Private Sub BindYearDropDown()
> lstAgendas.DataSource =
> BoardBO.GetADataSet("spAgendas_GetAllAgendaYears").Tables(0)
> lstAgendas.DataTextField = "Year"
> lstAgendas.DataValueField = "Year"
> lstAgendas.DataBind()
> End Sub
> Low and behold, I got all five years once again (2004 - 2000)!
> What is it about doing this with a DataSet instead of a DataReader that
> gives me all my data? Why is the DataReader method loosing the first row
in
> the returned records? I don't understand this.
> If you can help me to understand what is happening, I sure would
appreciate
> it. Thanks!!
> -- Andrew
Damn, I took all that time and effort to write up the message and you go an
solve it in three lines. I guess .Net is more productive. :) Thanks for
the help, it was right on the money!

-- Andrew

"Marina" <someone@.nospam.com> wrote in message
news:uxq6d$lHEHA.1220@.tk2msftngp13.phx.gbl...
> You call .Read before you return the erader - which advances the reader to
> the first row. I assume your problem is always missing the first row from
> the result set? Well, this is why.
> "Andrew" <AndrewR2k1@.hotmail.com> wrote in message
> news:eKv185lHEHA.828@.TK2MSFTNGP12.phx.gbl...
> > Hey all,
> > Have a strange one here, and being still fairly new to .NET isn't
helping
> me
> > understand it.
> > I am having a problem where a DataReader doesn't return all the rows
when
> I
> > try to use a method from a separate class file that returns a
DataReader,
> > where when I code the DataReader in the .aspx file it does. Below are
the
> > details and code of what I am runnign into. I appreciate any
help/insight
> > you can provide.
> > I am working on a fairly simple app that allow a user to
add/update/delete
> > meeting minutes and agendas. I have a database (SQL Server 2000)
storing
> > some simple info, and a directory the Mins/Agnd PDF file is uploaded to.
> I
> > created a little web user control that uses a DataGrid and DropDown
> listbox.
> > I bind each one separately, and use stored procedures to query the DB.
> > Originally I did the following function, called in the page's OnLoad
> method
> > only if Page.IsPostback was false:
> > Private Sub BindYearDropDown()
> > Dim con As New
> > SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
> > Dim cmd As SqlCommand = New SqlCommand("spAgendas_GetAllAgendaYears",
> con)
> > lstAgendas.DataSource =
> cmd.ExecuteReader(CommandBehavior.CloseConnection)
> > lstAgendas.DataTextField = "Year"
> > lstAgendas.DataValueField = "Year"
> > lstAgendas.DataBind()
> > End Sub
> > (My S-Proc is a basic "SELECT DISTINCT vYear FROM MyTable ORDER BY vYear
> > DESC")
> > All this does is populate a DropDown list with the distinct years in the
> DB
> > (2000 through 2004 in my case). I decided to use a DataReader beacuase
I
> am
> > not doing two-way communication, and also the DR runs much faster due to
> > lesser overhead requirements. Well, as I was building this app, I
started
> > to have more and more methods needing to talk to the DB. Well, I wanted
> to
> > create a single function that I could just call and it would return a
set
> of
> > records that I could rummage through or bind to data sources. This way
I
> > could just reuse the same method over and over, and if anything in my DB
> > connection changed, I didn't have to worry about finding all the
location
> > throughout the app and missing some change.
> > So, I created the following function in a "business objects" class file:
> > Public Function GetADataReader(ByVal sSQL As String) As
SqlDataReader
> > Dim con As New
> > SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
> > Dim cmd As SqlCommand = New SqlCommand(sSQL, con)
> > Dim dr As SqlDataReader
> > Try
> > con.Open()
> > dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
> > dr.Read()
> > Return dr
> > Catch ex As Exception
> > Throw
> > End Try
> > End Function
> > And then I altered my binding method back in my control to the following
> > (BoardBO is my "business objects" class file):
> > Private Sub BindYearDropDown()
> > lstAgendas.DataSource =
> > BoardBO.GetADataReader("spAgendas_GetAllAgendaYears")
> > lstAgendas.DataTextField = "Year"
> > lstAgendas.DataValueField = "Year"
> > lstAgendas.DataBind()
> > End Sub
> > And now we get to my question/problem. When I did it the first way, I
got
> > all five years (2004 through 2000). Yet when I do it the second way, I
> only
> > get 4 years (2003 through 2000). I debugged the code by adding a
> breakpoint
> > on the GetADataReader method and stepping through it one line at a time.
> > After the dr.Read() call, in the command window I typed "?dr(0)" and it
> gave
> > me "2004", yet once the DataBind() method of the BindYearDropDown method
> is
> > called, "2004" is nowhere to be seen. Huh? I don't get this.
> > Wondering if it was something about a "remote" DataReader method, I also
> > created a "remote" DataSet method to do the exact same thing, but using
a
> > DataSet object vice a SQLDataReader. That function is :
> > Public Function GetADataSet(ByVal sSQL As String) As DataSet
> > Dim con As String =
> > ConfigurationSettings.AppSettings("SQLServer_BOS")
> > Dim da As New SqlDataAdapter(sSQL, con)
> > Dim ds As New DataSet
> > Try
> > da.Fill(ds)
> > Return ds
> > Catch ex As Exception
> > Throw
> > End Try
> > End Function
> > And then I changed my dropdown list data bind method to:
> > Private Sub BindYearDropDown()
> > lstAgendas.DataSource =
> > BoardBO.GetADataSet("spAgendas_GetAllAgendaYears").Tables(0)
> > lstAgendas.DataTextField = "Year"
> > lstAgendas.DataValueField = "Year"
> > lstAgendas.DataBind()
> > End Sub
> > Low and behold, I got all five years once again (2004 - 2000)!
> > What is it about doing this with a DataSet instead of a DataReader that
> > gives me all my data? Why is the DataReader method loosing the first
row
> in
> > the returned records? I don't understand this.
> > If you can help me to understand what is happening, I sure would
> appreciate
> > it. Thanks!!
> > -- Andrew
Damn, I took all that time and effort to write up the message and you go an
solve it in three lines. I guess .Net is more productive. :) Thanks for
the help, it was right on the money!

-- Andrew

"Marina" <someone@.nospam.com> wrote in message
news:uxq6d$lHEHA.1220@.tk2msftngp13.phx.gbl...
> You call .Read before you return the erader - which advances the reader to
> the first row. I assume your problem is always missing the first row from
> the result set? Well, this is why.
> "Andrew" <AndrewR2k1@.hotmail.com> wrote in message
> news:eKv185lHEHA.828@.TK2MSFTNGP12.phx.gbl...
> > Hey all,
> > Have a strange one here, and being still fairly new to .NET isn't
helping
> me
> > understand it.
> > I am having a problem where a DataReader doesn't return all the rows
when
> I
> > try to use a method from a separate class file that returns a
DataReader,
> > where when I code the DataReader in the .aspx file it does. Below are
the
> > details and code of what I am runnign into. I appreciate any
help/insight
> > you can provide.
> > I am working on a fairly simple app that allow a user to
add/update/delete
> > meeting minutes and agendas. I have a database (SQL Server 2000)
storing
> > some simple info, and a directory the Mins/Agnd PDF file is uploaded to.
> I
> > created a little web user control that uses a DataGrid and DropDown
> listbox.
> > I bind each one separately, and use stored procedures to query the DB.
> > Originally I did the following function, called in the page's OnLoad
> method
> > only if Page.IsPostback was false:
> > Private Sub BindYearDropDown()
> > Dim con As New
> > SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
> > Dim cmd As SqlCommand = New SqlCommand("spAgendas_GetAllAgendaYears",
> con)
> > lstAgendas.DataSource =
> cmd.ExecuteReader(CommandBehavior.CloseConnection)
> > lstAgendas.DataTextField = "Year"
> > lstAgendas.DataValueField = "Year"
> > lstAgendas.DataBind()
> > End Sub
> > (My S-Proc is a basic "SELECT DISTINCT vYear FROM MyTable ORDER BY vYear
> > DESC")
> > All this does is populate a DropDown list with the distinct years in the
> DB
> > (2000 through 2004 in my case). I decided to use a DataReader beacuase
I
> am
> > not doing two-way communication, and also the DR runs much faster due to
> > lesser overhead requirements. Well, as I was building this app, I
started
> > to have more and more methods needing to talk to the DB. Well, I wanted
> to
> > create a single function that I could just call and it would return a
set
> of
> > records that I could rummage through or bind to data sources. This way
I
> > could just reuse the same method over and over, and if anything in my DB
> > connection changed, I didn't have to worry about finding all the
location
> > throughout the app and missing some change.
> > So, I created the following function in a "business objects" class file:
> > Public Function GetADataReader(ByVal sSQL As String) As
SqlDataReader
> > Dim con As New
> > SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
> > Dim cmd As SqlCommand = New SqlCommand(sSQL, con)
> > Dim dr As SqlDataReader
> > Try
> > con.Open()
> > dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
> > dr.Read()
> > Return dr
> > Catch ex As Exception
> > Throw
> > End Try
> > End Function
> > And then I altered my binding method back in my control to the following
> > (BoardBO is my "business objects" class file):
> > Private Sub BindYearDropDown()
> > lstAgendas.DataSource =
> > BoardBO.GetADataReader("spAgendas_GetAllAgendaYears")
> > lstAgendas.DataTextField = "Year"
> > lstAgendas.DataValueField = "Year"
> > lstAgendas.DataBind()
> > End Sub
> > And now we get to my question/problem. When I did it the first way, I
got
> > all five years (2004 through 2000). Yet when I do it the second way, I
> only
> > get 4 years (2003 through 2000). I debugged the code by adding a
> breakpoint
> > on the GetADataReader method and stepping through it one line at a time.
> > After the dr.Read() call, in the command window I typed "?dr(0)" and it
> gave
> > me "2004", yet once the DataBind() method of the BindYearDropDown method
> is
> > called, "2004" is nowhere to be seen. Huh? I don't get this.
> > Wondering if it was something about a "remote" DataReader method, I also
> > created a "remote" DataSet method to do the exact same thing, but using
a
> > DataSet object vice a SQLDataReader. That function is :
> > Public Function GetADataSet(ByVal sSQL As String) As DataSet
> > Dim con As String =
> > ConfigurationSettings.AppSettings("SQLServer_BOS")
> > Dim da As New SqlDataAdapter(sSQL, con)
> > Dim ds As New DataSet
> > Try
> > da.Fill(ds)
> > Return ds
> > Catch ex As Exception
> > Throw
> > End Try
> > End Function
> > And then I changed my dropdown list data bind method to:
> > Private Sub BindYearDropDown()
> > lstAgendas.DataSource =
> > BoardBO.GetADataSet("spAgendas_GetAllAgendaYears").Tables(0)
> > lstAgendas.DataTextField = "Year"
> > lstAgendas.DataValueField = "Year"
> > lstAgendas.DataBind()
> > End Sub
> > Low and behold, I got all five years once again (2004 - 2000)!
> > What is it about doing this with a DataSet instead of a DataReader that
> > gives me all my data? Why is the DataReader method loosing the first
row
> in
> > the returned records? I don't understand this.
> > If you can help me to understand what is happening, I sure would
> appreciate
> > it. Thanks!!
> > -- Andrew

Missing Rows in a DataBind()

Hey all,

Have a strange one here, and being still fairly new to .NET isn't helping me
understand it.

I am having a problem where a DataReader doesn't return all the rows when I
try to use a method from a separate class file that returns a DataReader,
where when I code the DataReader in the .aspx file it does. Below are the
details and code of what I am runnign into. I appreciate any help/insight
you can provide.

I am working on a fairly simple app that allow a user to add/update/delete
meeting minutes and agendas. I have a database (SQL Server 2000) storing
some simple info, and a directory the Mins/Agnd PDF file is uploaded to. I
created a little web user control that uses a DataGrid and DropDown listbox.
I bind each one separately, and use stored procedures to query the DB.

Originally I did the following function, called in the page's OnLoad method
only if Page.IsPostback was false:

Private Sub BindYearDropDown()
Dim con As New
SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
Dim cmd As SqlCommand = New SqlCommand("spAgendas_GetAllAgendaYears", con)
lstAgendas.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection)
lstAgendas.DataTextField = "Year"
lstAgendas.DataValueField = "Year"
lstAgendas.DataBind()
End Sub

(My S-Proc is a basic "SELECT DISTINCT vYear FROM MyTable ORDER BY vYear
DESC")

All this does is populate a DropDown list with the distinct years in the DB
(2000 through 2004 in my case). I decided to use a DataReader beacuase I am
not doing two-way communication, and also the DR runs much faster due to
lesser overhead requirements. Well, as I was building this app, I started
to have more and more methods needing to talk to the DB. Well, I wanted to
create a single function that I could just call and it would return a set of
records that I could rummage through or bind to data sources. This way I
could just reuse the same method over and over, and if anything in my DB
connection changed, I didn't have to worry about finding all the location
throughout the app and missing some change.

So, I created the following function in a "business objects" class file:

Public Function GetADataReader(ByVal sSQL As String) As SqlDataReader
Dim con As New
SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
Dim cmd As SqlCommand = New SqlCommand(sSQL, con)
Dim dr As SqlDataReader
Try
con.Open()
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
dr.Read()
Return dr
Catch ex As Exception
Throw
End Try
End Function

And then I altered my binding method back in my control to the following
(BoardBO is my "business objects" class file):

Private Sub BindYearDropDown()

lstAgendas.DataSource =
BoardBO.GetADataReader("spAgendas_GetAllAgendaYears")
lstAgendas.DataTextField = "Year"
lstAgendas.DataValueField = "Year"
lstAgendas.DataBind()

End Sub

And now we get to my question/problem. When I did it the first way, I got
all five years (2004 through 2000). Yet when I do it the second way, I only
get 4 years (2003 through 2000). I debugged the code by adding a breakpoint
on the GetADataReader method and stepping through it one line at a time.
After the dr.Read() call, in the command window I typed "?dr(0)" and it gave
me "2004", yet once the DataBind() method of the BindYearDropDown method is
called, "2004" is nowhere to be seen. Huh? I don't get this.

Wondering if it was something about a "remote" DataReader method, I also
created a "remote" DataSet method to do the exact same thing, but using a
DataSet object vice a SQLDataReader. That function is :

Public Function GetADataSet(ByVal sSQL As String) As DataSet
Dim con As String =
ConfigurationSettings.AppSettings("SQLServer_BOS")
Dim da As New SqlDataAdapter(sSQL, con)
Dim ds As New DataSet
Try
da.Fill(ds)
Return ds
Catch ex As Exception
Throw
End Try
End Function

And then I changed my dropdown list data bind method to:

Private Sub BindYearDropDown()

lstAgendas.DataSource =
BoardBO.GetADataSet("spAgendas_GetAllAgendaYears").Tables(0)
lstAgendas.DataTextField = "Year"
lstAgendas.DataValueField = "Year"
lstAgendas.DataBind()

End Sub

Low and behold, I got all five years once again (2004 - 2000)!

What is it about doing this with a DataSet instead of a DataReader that
gives me all my data? Why is the DataReader method loosing the first row in
the returned records? I don't understand this.

If you can help me to understand what is happening, I sure would appreciate
it. Thanks!!

-- AndrewYou call .Read before you return the erader - which advances the reader to
the first row. I assume your problem is always missing the first row from
the result set? Well, this is why.

"Andrew" <AndrewR2k1@.hotmail.com> wrote in message
news:eKv185lHEHA.828@.TK2MSFTNGP12.phx.gbl...
> Hey all,
> Have a strange one here, and being still fairly new to .NET isn't helping
me
> understand it.
> I am having a problem where a DataReader doesn't return all the rows when
I
> try to use a method from a separate class file that returns a DataReader,
> where when I code the DataReader in the .aspx file it does. Below are the
> details and code of what I am runnign into. I appreciate any help/insight
> you can provide.
> I am working on a fairly simple app that allow a user to add/update/delete
> meeting minutes and agendas. I have a database (SQL Server 2000) storing
> some simple info, and a directory the Mins/Agnd PDF file is uploaded to.
I
> created a little web user control that uses a DataGrid and DropDown
listbox.
> I bind each one separately, and use stored procedures to query the DB.
> Originally I did the following function, called in the page's OnLoad
method
> only if Page.IsPostback was false:
> Private Sub BindYearDropDown()
> Dim con As New
> SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
> Dim cmd As SqlCommand = New SqlCommand("spAgendas_GetAllAgendaYears",
con)
> lstAgendas.DataSource =
cmd.ExecuteReader(CommandBehavior.CloseConnection)
> lstAgendas.DataTextField = "Year"
> lstAgendas.DataValueField = "Year"
> lstAgendas.DataBind()
> End Sub
> (My S-Proc is a basic "SELECT DISTINCT vYear FROM MyTable ORDER BY vYear
> DESC")
> All this does is populate a DropDown list with the distinct years in the
DB
> (2000 through 2004 in my case). I decided to use a DataReader beacuase I
am
> not doing two-way communication, and also the DR runs much faster due to
> lesser overhead requirements. Well, as I was building this app, I started
> to have more and more methods needing to talk to the DB. Well, I wanted
to
> create a single function that I could just call and it would return a set
of
> records that I could rummage through or bind to data sources. This way I
> could just reuse the same method over and over, and if anything in my DB
> connection changed, I didn't have to worry about finding all the location
> throughout the app and missing some change.
> So, I created the following function in a "business objects" class file:
> Public Function GetADataReader(ByVal sSQL As String) As SqlDataReader
> Dim con As New
> SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
> Dim cmd As SqlCommand = New SqlCommand(sSQL, con)
> Dim dr As SqlDataReader
> Try
> con.Open()
> dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
> dr.Read()
> Return dr
> Catch ex As Exception
> Throw
> End Try
> End Function
> And then I altered my binding method back in my control to the following
> (BoardBO is my "business objects" class file):
> Private Sub BindYearDropDown()
> lstAgendas.DataSource =
> BoardBO.GetADataReader("spAgendas_GetAllAgendaYears")
> lstAgendas.DataTextField = "Year"
> lstAgendas.DataValueField = "Year"
> lstAgendas.DataBind()
> End Sub
> And now we get to my question/problem. When I did it the first way, I got
> all five years (2004 through 2000). Yet when I do it the second way, I
only
> get 4 years (2003 through 2000). I debugged the code by adding a
breakpoint
> on the GetADataReader method and stepping through it one line at a time.
> After the dr.Read() call, in the command window I typed "?dr(0)" and it
gave
> me "2004", yet once the DataBind() method of the BindYearDropDown method
is
> called, "2004" is nowhere to be seen. Huh? I don't get this.
> Wondering if it was something about a "remote" DataReader method, I also
> created a "remote" DataSet method to do the exact same thing, but using a
> DataSet object vice a SQLDataReader. That function is :
> Public Function GetADataSet(ByVal sSQL As String) As DataSet
> Dim con As String =
> ConfigurationSettings.AppSettings("SQLServer_BOS")
> Dim da As New SqlDataAdapter(sSQL, con)
> Dim ds As New DataSet
> Try
> da.Fill(ds)
> Return ds
> Catch ex As Exception
> Throw
> End Try
> End Function
> And then I changed my dropdown list data bind method to:
> Private Sub BindYearDropDown()
> lstAgendas.DataSource =
> BoardBO.GetADataSet("spAgendas_GetAllAgendaYears").Tables(0)
> lstAgendas.DataTextField = "Year"
> lstAgendas.DataValueField = "Year"
> lstAgendas.DataBind()
> End Sub
> Low and behold, I got all five years once again (2004 - 2000)!
> What is it about doing this with a DataSet instead of a DataReader that
> gives me all my data? Why is the DataReader method loosing the first row
in
> the returned records? I don't understand this.
> If you can help me to understand what is happening, I sure would
appreciate
> it. Thanks!!
> -- Andrew
Damn, I took all that time and effort to write up the message and you go an
solve it in three lines. I guess .Net is more productive. :) Thanks for
the help, it was right on the money!

-- Andrew

"Marina" <someone@.nospam.com> wrote in message
news:uxq6d$lHEHA.1220@.tk2msftngp13.phx.gbl...
> You call .Read before you return the erader - which advances the reader to
> the first row. I assume your problem is always missing the first row from
> the result set? Well, this is why.
> "Andrew" <AndrewR2k1@.hotmail.com> wrote in message
> news:eKv185lHEHA.828@.TK2MSFTNGP12.phx.gbl...
> > Hey all,
> > Have a strange one here, and being still fairly new to .NET isn't
helping
> me
> > understand it.
> > I am having a problem where a DataReader doesn't return all the rows
when
> I
> > try to use a method from a separate class file that returns a
DataReader,
> > where when I code the DataReader in the .aspx file it does. Below are
the
> > details and code of what I am runnign into. I appreciate any
help/insight
> > you can provide.
> > I am working on a fairly simple app that allow a user to
add/update/delete
> > meeting minutes and agendas. I have a database (SQL Server 2000)
storing
> > some simple info, and a directory the Mins/Agnd PDF file is uploaded to.
> I
> > created a little web user control that uses a DataGrid and DropDown
> listbox.
> > I bind each one separately, and use stored procedures to query the DB.
> > Originally I did the following function, called in the page's OnLoad
> method
> > only if Page.IsPostback was false:
> > Private Sub BindYearDropDown()
> > Dim con As New
> > SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
> > Dim cmd As SqlCommand = New SqlCommand("spAgendas_GetAllAgendaYears",
> con)
> > lstAgendas.DataSource =
> cmd.ExecuteReader(CommandBehavior.CloseConnection)
> > lstAgendas.DataTextField = "Year"
> > lstAgendas.DataValueField = "Year"
> > lstAgendas.DataBind()
> > End Sub
> > (My S-Proc is a basic "SELECT DISTINCT vYear FROM MyTable ORDER BY vYear
> > DESC")
> > All this does is populate a DropDown list with the distinct years in the
> DB
> > (2000 through 2004 in my case). I decided to use a DataReader beacuase
I
> am
> > not doing two-way communication, and also the DR runs much faster due to
> > lesser overhead requirements. Well, as I was building this app, I
started
> > to have more and more methods needing to talk to the DB. Well, I wanted
> to
> > create a single function that I could just call and it would return a
set
> of
> > records that I could rummage through or bind to data sources. This way
I
> > could just reuse the same method over and over, and if anything in my DB
> > connection changed, I didn't have to worry about finding all the
location
> > throughout the app and missing some change.
> > So, I created the following function in a "business objects" class file:
> > Public Function GetADataReader(ByVal sSQL As String) As
SqlDataReader
> > Dim con As New
> > SqlConnection(ConfigurationSettings.AppSettings("SQLServer_BOS"))
> > Dim cmd As SqlCommand = New SqlCommand(sSQL, con)
> > Dim dr As SqlDataReader
> > Try
> > con.Open()
> > dr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
> > dr.Read()
> > Return dr
> > Catch ex As Exception
> > Throw
> > End Try
> > End Function
> > And then I altered my binding method back in my control to the following
> > (BoardBO is my "business objects" class file):
> > Private Sub BindYearDropDown()
> > lstAgendas.DataSource =
> > BoardBO.GetADataReader("spAgendas_GetAllAgendaYears")
> > lstAgendas.DataTextField = "Year"
> > lstAgendas.DataValueField = "Year"
> > lstAgendas.DataBind()
> > End Sub
> > And now we get to my question/problem. When I did it the first way, I
got
> > all five years (2004 through 2000). Yet when I do it the second way, I
> only
> > get 4 years (2003 through 2000). I debugged the code by adding a
> breakpoint
> > on the GetADataReader method and stepping through it one line at a time.
> > After the dr.Read() call, in the command window I typed "?dr(0)" and it
> gave
> > me "2004", yet once the DataBind() method of the BindYearDropDown method
> is
> > called, "2004" is nowhere to be seen. Huh? I don't get this.
> > Wondering if it was something about a "remote" DataReader method, I also
> > created a "remote" DataSet method to do the exact same thing, but using
a
> > DataSet object vice a SQLDataReader. That function is :
> > Public Function GetADataSet(ByVal sSQL As String) As DataSet
> > Dim con As String =
> > ConfigurationSettings.AppSettings("SQLServer_BOS")
> > Dim da As New SqlDataAdapter(sSQL, con)
> > Dim ds As New DataSet
> > Try
> > da.Fill(ds)
> > Return ds
> > Catch ex As Exception
> > Throw
> > End Try
> > End Function
> > And then I changed my dropdown list data bind method to:
> > Private Sub BindYearDropDown()
> > lstAgendas.DataSource =
> > BoardBO.GetADataSet("spAgendas_GetAllAgendaYears").Tables(0)
> > lstAgendas.DataTextField = "Year"
> > lstAgendas.DataValueField = "Year"
> > lstAgendas.DataBind()
> > End Sub
> > Low and behold, I got all five years once again (2004 - 2000)!
> > What is it about doing this with a DataSet instead of a DataReader that
> > gives me all my data? Why is the DataReader method loosing the first
row
> in
> > the returned records? I don't understand this.
> > If you can help me to understand what is happening, I sure would
> appreciate
> > it. Thanks!!
> > -- Andrew

Missing Session!

I have a problem with my sessions , I'm not so sure what make this happens .
My session_end event happens in places that it's not expected for example when I start a new session session start event happens and before my page load event occurs the session_end occurs , even sometimes when I use my login form right after i write a session and redirect browser to other page this event happens and made all my variables in session state become unavailable , I try so hard to find the reason but i found nothing
Anyone have same problem or already know the reason
ThanksHi, Alireza Ziai,

From what you explained (and from what I understood) I think the following
article is should resolve your problem, which seems to be session data that
is lost because of antivirus software activity:

http://support.microsoft.com/?id=316148

Greetings
Martin
"Alireza Ziai" <zialireza@.yahoo.com> wrote in message
news:9107AB16-79D3-49C7-90A7-51AE13620A8F@.microsoft.com...
> I have a problem with my sessions , I'm not so sure what make this happens
..
> My session_end event happens in places that it's not expected for example
when I start a new session session start event happens and before my page
load event occurs the session_end occurs , even sometimes when I use my
login form right after i write a session and redirect browser to other page
this event happens and made all my variables in session state become
unavailable , I try so hard to find the reason but i found nothing.
> Anyone have same problem or already know the reason?
> Thanks
Thanks alot Martin it works!

Missing something basic

Hi, new to .Net and I seem to be missing something basic.

From I what I have read so far I have gained the impression that ViewState is used to describe the way a .Net form retains the data in controls on that form.

But I have just seen a bit of code that, after retrieving a ContactID from a database then says

Code:
ViewState["ContactID"] = ContactID;
but there is no control on the form called ContactID - so what is being set?

And ...

what is the correct way to do the following ...

Say I pass a companyID to a page like:
<a href="http://links.10026.com/?link=CompanyDetails.aspx?CoID=25">Show Details</a>

and, on that page I run a procedure that returns the company name - which I want to hang on to then regardless of how many times that page is posted back to.

My instincts are to retrieve the company name and stick it in a <asp:HiddenField> and retrieve it each time the page is posted back.

Is this okay?

CheersViewState is a dictionary that is serialized into an encoded string as the page is about render. This encoded string is sent to the client - as you can clearly see if you do a 'view..source' from IE after requesting an ASPX page.

When the client browser posts back to the server, that encoded string is used to populate a ViewState dictionary again. ViewState allows stateful storage of control data by putting that data directly in the html document passed back and forth. Once all the controls are loaded and initalized, the ViewState is inspected and control properties are set to the same 'state' as when the page was sent to the client.

ASP.NET server controls make use of this dictionary, and so can you. The framework doesn't care what adds items to viewstate. That said, you shouldn't pull a LOT of data in Viewstate because it has to be encoded to a string that is sent back and forth all the time.

There's also Session state, and Application state, and the HttpRuntime state.
Thanks for your reply.

So when I see code like this:

ViewState["ContactID"] = ContactID;

it means that the value of ContactID is being 'put into' ViewState and can be retrieved using Request("ContactID") - even though there is no control called 'ContactID'?
Yes, but you retrieve the value by using

if (ViewState["ContactID"] != null)
contactId = ViewState["ContactID"];

Request["ContactID"] would attempt to retrieve a value from the http <form> that was posted by the client.

So in the case of your hidden input field (which is all ViewState is underneath), you could retrieve its value the manual way by using Request["myHiddenInputField"].But the more acceptable ASP.NET way is to mark the hidden input field to run as a server control in your aspx markup, declare it in your related web page class (codebehind), and check its Value property.

aspx:
<form>
<input type="hidden" runat="server" id="myHiddenInput" />
</form>

and in the page_load event (C#):

class WebPage1
{
protected HtmlInputHidden myHiddenInput;

Page_Load
{
string lookAtMe = myHiddenInput.Value;
}

http://msdn2.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlinputhidden.aspx
Right - thanks for that. Got the picture now.

Cheers

Missing Something on pageBaseType?

The documentation on the <page> element on the configuration file states--

pageBaseType Specifies a code-behind class that .aspx pages inherit by
default.

I have tried everything I can think of and have managed to get the
configuration file to be processed without error but have not managed to get
the Page Base Type set to my class. Am I missing something here?

I'm using VS 2003 and can use my class by editing it into a page but have
not been able to get it in using pageBaseType.

Thank YouHow did you specify the value for it?I believe it needs to be
pageBaseType="assemblyName, typeName" format. Is it that way?

--
Girish Bharadwaj
http://msmvps.com/gbvb
"Perley" <Perley@.newsgroup.nospam> wrote in message
news:9AB1F820-3D33-4FA0-A262-E824BC960DDF@.microsoft.com...
> The documentation on the <page> element on the configuration file states--
> pageBaseType Specifies a code-behind class that .aspx pages inherit by
> default.
> I have tried everything I can think of and have managed to get the
> configuration file to be processed without error but have not managed to
get
> the Page Base Type set to my class. Am I missing something here?
> I'm using VS 2003 and can use my class by editing it into a page but have
> not been able to get it in using pageBaseType.
> Thank You
Actually I have pageBaseType="typeName, assemblyName" Which is the only
thing that would allow the config file to be processed without error.

"Girish Bharadwaj" wrote:

> How did you specify the value for it?I believe it needs to be
> pageBaseType="assemblyName, typeName" format. Is it that way?
> --
> Girish Bharadwaj
> http://msmvps.com/gbvb
> "Perley" <Perley@.newsgroup.nospam> wrote in message
> news:9AB1F820-3D33-4FA0-A262-E824BC960DDF@.microsoft.com...
> > The documentation on the <page> element on the configuration file states--
> > pageBaseType Specifies a code-behind class that .aspx pages inherit by
> > default.
> > I have tried everything I can think of and have managed to get the
> > configuration file to be processed without error but have not managed to
> get
> > the Page Base Type set to my class. Am I missing something here?
> > I'm using VS 2003 and can use my class by editing it into a page but have
> > not been able to get it in using pageBaseType.
> > Thank You
>
You are right. I am wrong.

I tried it with a couple hand-coded (instead of VS.NET) aspx file +
assembly. And it works just fine.
So, I think the problem is that VS.NET does this trick with ASPX pages which
is to create that aspx.cs files which are the base class for the actual ASPX
file. And, of course, VS.NET depends on that relation for things to work.
Basically, the use of <Inherits> attribute on @.Page states that you want to
use a particular class as the base class explicitly.

I guess, you are stuck. Because, there is an intermediary class derived
from Page class which is the base for the ASPX page. If you remove the
"Inherits" from that attribute, it will probably work. But then, VS.NET
will re-insert it again when you edit the file.
Good news is that VS.NET 2005 fixes it but the bad news is that, well, it
aint here.

Of course, somebody else might have a better idea.

--
Girish Bharadwaj
http://msmvps.com/gbvb
"Perley" <Perley@.newsgroup.nospam> wrote in message
news:1D39F295-45BA-4F0F-B56E-34B4517DCEB6@.microsoft.com...
> Actually I have pageBaseType="typeName, assemblyName" Which is the only
> thing that would allow the config file to be processed without error.
> "Girish Bharadwaj" wrote:
> > How did you specify the value for it?I believe it needs to be
> > pageBaseType="assemblyName, typeName" format. Is it that way?
> > --
> > Girish Bharadwaj
> > http://msmvps.com/gbvb
> > "Perley" <Perley@.newsgroup.nospam> wrote in message
> > news:9AB1F820-3D33-4FA0-A262-E824BC960DDF@.microsoft.com...
> > > The documentation on the <page> element on the configuration file
states--
> > > > pageBaseType Specifies a code-behind class that .aspx pages inherit by
> > > default.
> > > > I have tried everything I can think of and have managed to get the
> > > configuration file to be processed without error but have not managed
to
> > get
> > > the Page Base Type set to my class. Am I missing something here?
> > > > I'm using VS 2003 and can use my class by editing it into a page but
have
> > > not been able to get it in using pageBaseType.
> > > > Thank You
Thanks. I wouldn't of thought of going outside of VS.NET (bad habit).

Story of my life ... out of luck

Thanks again.

"Girish Bharadwaj" wrote:

> You are right. I am wrong.
> I tried it with a couple hand-coded (instead of VS.NET) aspx file +
> assembly. And it works just fine.
> So, I think the problem is that VS.NET does this trick with ASPX pages which
> is to create that aspx.cs files which are the base class for the actual ASPX
> file. And, of course, VS.NET depends on that relation for things to work.
> Basically, the use of <Inherits> attribute on @.Page states that you want to
> use a particular class as the base class explicitly.
> I guess, you are stuck. Because, there is an intermediary class derived
> from Page class which is the base for the ASPX page. If you remove the
> "Inherits" from that attribute, it will probably work. But then, VS.NET
> will re-insert it again when you edit the file.
> Good news is that VS.NET 2005 fixes it but the bad news is that, well, it
> aint here.
> Of course, somebody else might have a better idea.
> --
> Girish Bharadwaj
> http://msmvps.com/gbvb
> "Perley" <Perley@.newsgroup.nospam> wrote in message
> news:1D39F295-45BA-4F0F-B56E-34B4517DCEB6@.microsoft.com...
> > Actually I have pageBaseType="typeName, assemblyName" Which is the only
> > thing that would allow the config file to be processed without error.
> > "Girish Bharadwaj" wrote:
> > > How did you specify the value for it?I believe it needs to be
> > > pageBaseType="assemblyName, typeName" format. Is it that way?
> > > > --
> > > Girish Bharadwaj
> > > http://msmvps.com/gbvb
> > > "Perley" <Perley@.newsgroup.nospam> wrote in message
> > > news:9AB1F820-3D33-4FA0-A262-E824BC960DDF@.microsoft.com...
> > > > The documentation on the <page> element on the configuration file
> states--
> > > > > > pageBaseType Specifies a code-behind class that .aspx pages inherit by
> > > > default.
> > > > > > I have tried everything I can think of and have managed to get the
> > > > configuration file to be processed without error but have not managed
> to
> > > get
> > > > the Page Base Type set to my class. Am I missing something here?
> > > > > > I'm using VS 2003 and can use my class by editing it into a page but
> have
> > > > not been able to get it in using pageBaseType.
> > > > > > Thank You
> > > >

Missing Something on pageBaseType?

The documentation on the <page> element on the configuration file states--
pageBaseType Specifies a code-behind class that .aspx pages inherit by
default.
I have tried everything I can think of and have managed to get the
configuration file to be processed without error but have not managed to get
the Page Base Type set to my class. Am I missing something here?
I'm using VS 2003 and can use my class by editing it into a page but have
not been able to get it in using pageBaseType.
Thank YouHow did you specify the value for it?I believe it needs to be
pageBaseType="assemblyName, typeName" format. Is it that way?
Girish Bharadwaj
http://msmvps.com/gbvb
"Perley" <Perley@.newsgroup.nospam> wrote in message
news:9AB1F820-3D33-4FA0-A262-E824BC960DDF@.microsoft.com...
> The documentation on the <page> element on the configuration file states--
> pageBaseType Specifies a code-behind class that .aspx pages inherit by
> default.
> I have tried everything I can think of and have managed to get the
> configuration file to be processed without error but have not managed to
get
> the Page Base Type set to my class. Am I missing something here?
> I'm using VS 2003 and can use my class by editing it into a page but have
> not been able to get it in using pageBaseType.
> Thank You
Actually I have pageBaseType="typeName, assemblyName" Which is the only
thing that would allow the config file to be processed without error.
"Girish Bharadwaj" wrote:

> How did you specify the value for it?I believe it needs to be
> pageBaseType="assemblyName, typeName" format. Is it that way?
> --
> Girish Bharadwaj
> http://msmvps.com/gbvb
> "Perley" <Perley@.newsgroup.nospam> wrote in message
> news:9AB1F820-3D33-4FA0-A262-E824BC960DDF@.microsoft.com...
> get
>
>
You are right. I am wrong.
I tried it with a couple hand-coded (instead of VS.NET) aspx file +
assembly. And it works just fine.
So, I think the problem is that VS.NET does this trick with ASPX pages which
is to create that aspx.cs files which are the base class for the actual ASPX
file. And, of course, VS.NET depends on that relation for things to work.
Basically, the use of <Inherits> attribute on @.Page states that you want to
use a particular class as the base class explicitly.
I guess, you are stuck. Because, there is an intermediary class derived
from Page class which is the base for the ASPX page. If you remove the
"Inherits" from that attribute, it will probably work. But then, VS.NET
will re-insert it again when you edit the file.
Good news is that VS.NET 2005 fixes it but the bad news is that, well, it
aint here.
Of course, somebody else might have a better idea.
Girish Bharadwaj
http://msmvps.com/gbvb
"Perley" <Perley@.newsgroup.nospam> wrote in message
news:1D39F295-45BA-4F0F-B56E-34B4517DCEB6@.microsoft.com...
> Actually I have pageBaseType="typeName, assemblyName" Which is the only
> thing that would allow the config file to be processed without error.
> "Girish Bharadwaj" wrote:
>
states--
to
have
Thanks. I wouldn't of thought of going outside of VS.NET (bad habit).
Story of my life ... out of luck
Thanks again.
"Girish Bharadwaj" wrote:

> You are right. I am wrong.
> I tried it with a couple hand-coded (instead of VS.NET) aspx file +
> assembly. And it works just fine.
> So, I think the problem is that VS.NET does this trick with ASPX pages whi
ch
> is to create that aspx.cs files which are the base class for the actual AS
PX
> file. And, of course, VS.NET depends on that relation for things to work.
> Basically, the use of <Inherits> attribute on @.Page states that you want t
o
> use a particular class as the base class explicitly.
> I guess, you are stuck. Because, there is an intermediary class derived
> from Page class which is the base for the ASPX page. If you remove the
> "Inherits" from that attribute, it will probably work. But then, VS.NET
> will re-insert it again when you edit the file.
> Good news is that VS.NET 2005 fixes it but the bad news is that, well, it
> aint here.
> Of course, somebody else might have a better idea.
> --
> Girish Bharadwaj
> http://msmvps.com/gbvb
> "Perley" <Perley@.newsgroup.nospam> wrote in message
> news:1D39F295-45BA-4F0F-B56E-34B4517DCEB6@.microsoft.com...
> states--
> to
> have
>
>

Missing something with Formviews/databinding

I have been struggling with something that I think ought to be so simple that I must just be missing some fundamental piece of the knowledge jigsaw. I am hoping someone here may be able to provide me with a "lightbulb moment".

I have a web application that accesses data from an SQL data source. I have implemented this as a data access layer using the data designer wizard talking directly to the server to create table adapters. I have table adapters for all the individual tables, and also some others that are the result of more complex views or joins. On top of the DAL I have a business layer that is what is actually called from the ASP pages. For standard stuff like gridviews and updating single tables then that is fine and all working.

But the problem I have is that I want to be able to lead my user through creation of new records in the database where they are not using a formview that is a one-to-one mapping with a table. For example, I have a Buildings table where each record includes things like utility references, comments etc, but also has a reference to a separate Addresses table that actually stores the address. There's a FK/PK relationship between Buildings and Addresses.

So what I wnant to do is have a wizard that prompts for the address, then moves on to ask for bits of the other building information, and finally at the end calls code that grabs this data and makes the necessary sequence of BLL calls to set it all up in whatever tables are under the hood. What I don't want to do is create a new address record early on in the wizard in case the operation gets aborted, for example.

Also, because I may have several variations on data gathering, I would like the address input/display form to be a custom control so I can reuse it elsewhere.

Now, if I try and do this with a FormView in one of the wizard steps, then the user gets a FormView generated "Insert" button that (a) gets in the way of my wizard navigation and (b) breaks my requirement of not updating the database until the final wizard step and under code control.

Now it struck me that all I really want is a FormView that gathers DataRow information of a type generated by the data designer as part of the table adapter. I don't actually want a connection to the database at this stage. But I have been unable to make this work.

My rather rubbish solution to this has been to create a contained class within the address control that stores the information in the form controls. I.e - something like this:

public partialclass AddressControl : System.Web.UI.UserControl{public class AddressData {private string _line1;public string Line1NumberBuilding {get {return _line1; }set { _line1 =value; } }private string _line2;public string Line2NumberStreet {get {return _line2; }set { _line2 =value; } }...etcfor all address fields }

And then also in the AddressControl:

private AddressData _address =new AddressData();public AddressData Address {get {return _address; }public void UpdateAddressData () { Address.Line1NumberBuilding = Line1NumberBuildingTextBox.Text; Address.Line2NumberStreet = Line2NumberStreetTextBox.Text; ...etcfor all fields... }
Finally, in my final wizard button click step I end up doing:
 AddressControl2.UpdateAddressData();int addressId = addressbll.AddAddress( AddressControl2.Address.Line1NumberBuilding, AddressControl2.Address.Line2NumberStreet, ...etc// do something with the new address id ...
Now this just seems barmy to me for a number of reasons. Firstly I am effectively repeating the information in the AddressDataRow record generated for my in the DAL. Secondly, I lose all databinding with my controls requiring the extremely ugly and unpleasant "UpdateAddressData" method in my customer control.

But the worse thing is that I have to write so much damn boilerplate code. I really want to pass address records around as objects, but I don't want my BLL to either use classes defined at the UI level (AddressData in this case) or to be forced to create such records as part of the BLL when the DataRow already does this.

I did try simply declaring an AddressDataRow object (derived from DataRow by the data designer), but they (a) cannot bind to my form and (b) cannot exist on their own - they always have to be part of a table adaptor.

I have read around a lot on this, but everything I find assumes you want to give complete control on the database create/update access over to FormView and also that one-form-equals-one-table in the database.

I would really appreciate any insight on this. Apologies for the long post but I hope the detail of it will help any answers. I suspect I am tackling the problem from the wrong direction - but I don't know which way to go!

*Bump*

Can anyone shine a light on this for me?


Honestly, the issue here is that you really don't want a form view. A formview represents, well, a form. In your case, you want a wizard that is in control. So your best bet is really just to put your own input fields in the wizard. Keep the results in viewstate or session in an object, and when your wizard is at the finish step, have a property for your control to return the gathered object to pass it to your DAL, or something of the sort.

Yeah its kind of boiler plate code, but 2 way databinding is really when you want a direct bridge to your DAL, and in this case you don't want that. The formview is a databinding controler, not an input control in itself, therefor it simply doesn't do what you want.

CAN it do exactly what you want? Yes. But its honestly lightyears easier to make your own solution for this. Keep using the wizard, but use a custom form. Personaly, the only databound control I use are the combo box/list box and the grid, and rarely, if ever, use 2 way databinding. If I do, then it will be with an ObjectDataSource with custom business code. Its unfortunate, but as soon as you go beyond the prototyping stage, you kindda need boiler plate code.


Thanks very much for the reply. Your middle paragraph has shone some light on things.

It's probably worth me saying that the "wizardness" of my original example is not really the heart of the problem. It's more that there is not a 1-to-1 relationship between the information I need to gather and a table in the database - hence your middle paragraph helping to clarify. I could just as easily lump all my wizard steps into a single from - it's just that this data will end up creating some new records in some tables, and updating some in others.

It looks like this two-way databinding for the database only ever really makes a good demo of MS technology then? Any non-trivial applications have to bypass this and do their own thing? Or, as you say, prototyping.


More or less. The idea behind these things is that a typical WEBSITE (as opposed to a web application), won't do much. Go to some online store's web site, and look. A navigation control...a data repeater for the product listing... maybe a form view for a survey... Obviously the actual checkout has 10 tons of code in it because of all the credit card and security stuff.

Thats what these things are for. And yes, for prototyping. For just about everything else, you'll either have your 100% custom business code and DAL, -or-, you will be using the Object Data Source (which allows you to visualy databind stuff, but you stay in full control, you don't even need a database at all!)