Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 15th, 2004, 03:13 PM
Authorized User
 
Join Date: Jul 2003
Location: Memphis, TN, USA.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default HELP!! GRID NOT BINDING

Hi all,
I have built my own version of the page 'news.aspx' (admin
section of NewsManager). On my page, I am not using the
radio buttons for 'all', 'approved only', etc. So I re-wrote
the code and the stored procedures. The page is loading but the
grid is empty. No change when I select names (category ids)
in the dropdownlist.
The code I am most concerned about--and the stored procedure, are
listed here:
<code>
Public Overloads Function GetAdminVendorEquipment() As DataSet
     Return GetAdminVendorEquipment(False)
End Function

Public Overloads Function GetAdminVendorEquipment( _
      ByVal PropCompanyId As Integer) _
      As DataSet

    Dim theAdminVendorEquipment As New Data.VendorEquipment
    (mySettings.ConnectionString)

    Return theAdminVendorEquipment.GetAdminVendorEquipment( _
    ReceptacleId, VendorSysId, VendorCompanyName, PropCompanyId,
    PropCompanyName, PropName, LocationDesc)

End Function
- - - - - - - - - - - - -

ALTER PROCEDURE sp_Properties_GetAdminVendorEquipment
@ReceptacleId int,
@VendorSysId varchar(25),
@VendorCompanyName varchar(50),
@PropCompanyId int,
@PropCompanyName varchar(50),
@PropName varchar(50),
@LocationDesc varchar(50)

AS
BEGIN
    SELECT ReceptacleId, VendorSysId, VendorCompanyName, PropCompanyId, PropCompanyName, PropName, LocationDesc FROM VendorEquipment WHERE PropCompanyId = @PropCompanyId
END
</code>
In the news.aspx page, the overloads function in category.vb
has 'ByVal currentApprovedOnly As Boolean' in the 'GetNews'
head statement. I'm not sure of the validity of replacing this
in my function with 'PropCompanyId As Integer'.--In my page,
'PropCompanyId' is the value (like categoryId) looked up with the
dropdownlist, and 'PropCompanyName' is the datatextfield displayed
in the dropdownlist.
If anyone has a suggestion what I might have done wrong, or if you
need to see other pieces, any help would be greatly appreciated.
Thx much,

R Corcoran, Jr.
__________________
Reid C.
 
Old June 16th, 2004, 07:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

The function:

Public Overloads Function GetAdminVendorEquipment() As DataSet
     Return GetAdminVendorEquipment(False)
End Function

Passes in a false value, but it should be an integer,right? By passing in a boolean to the other function, you are passing in zero, which unless you start ID's at zero, no results would be returned... Which function are you using to retrieve the data?

Your query appears fine, although you don't need the begin and end:

BEGIN
    SELECT ReceptacleId, VendorSysId, VendorCompanyName, PropCompanyId, PropCompanyName, PropName, LocationDesc FROM VendorEquipment WHERE PropCompanyId = @PropCompanyId
END

Brian
 
Old June 16th, 2004, 12:08 PM
Authorized User
 
Join Date: Jul 2003
Location: Memphis, TN, USA.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Brian,
thanks for your help and suggestions...
the boolean ("currentapprovedonly as Boolean") was the
passed-in parameter of the original "getnews" function
found in thephile's newsmanager.business.category.vb
class.
Since I do not have the radio buttons and I am just
binding the grid from the "PropCompanyId" value I
select in the dropdownlist, I do not know exactly how to
re-code the "Public Overloads Function GetNews" (my "Public
Overloads Function GetAdminVendorEquipment") since there is
no such boolean as 'currentapprovedonly' and no radio buttons.
So I do not know what to put in the (), just that my choice,
'ByVal PropCompanyId As Integer' does not work. I just want to get
the grid to load (bind) from the choice in the dropdownlist of
'PropCompanyId' that is chosen.
Can you help w/ a suggestion on this?
Thx much again...

R Corcoran, Jr.
 
Old June 16th, 2004, 02:48 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

If you aren't using that method, just get rid of it; that will solve any problems, because calling it with false will equate to zero for the ID.

In the return statement of this method, I don't understand where the values ReceptacleId, VendorSysId, VendorCompanyName, PropCompanyName, PropName, LocationDesc are being provided.

Public Overloads Function GetAdminVendorEquipment( _
      ByVal PropCompanyId As Integer) _
      As DataSet

    Dim theAdminVendorEquipment As New Data.VendorEquipment
    (mySettings.ConnectionString)

    Return theAdminVendorEquipment.GetAdminVendorEquipment( _
    ReceptacleId, VendorSysId, VendorCompanyName, PropCompanyId,
    PropCompanyName, PropName, LocationDesc)
End Function

Are these functions at the page level, on in an external (of the page) class? I don't see where these variables are being populated... If those equate to nothing, and you query based on those, that might not return any results for you.

Could that be the problem?

Thanks,

Brian
 
Old June 16th, 2004, 10:01 PM
Authorized User
 
Join Date: Jul 2003
Location: Memphis, TN, USA.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Brian,
thanks again...
first, I will try getting rid of the first overloads
function (the one that returns "getAdmin...(False)")
and see if that helps.
As to your question about where these functions are
placed, if you are familiar with the set-up of the
'thePhileVB' website, then what I am working on is
constructed the same way; so there is page code
(.aspx), there is code-behind (.aspx.vb), then there
are both data and business tiers. These functions are
located in the business tier.

Also, I am a novice to Visual Basic.Net language and to
coding in general. I'm learning as I'm going along. So
one questions that just came to mind: if I don't need
the first of the functions, and I'm not "altering" what
the grid 'binds' by the radio buttons, do I need a
"overloads" function, or should this just be a 'public
function GetAdminVendorEquipment' ?
Thx again,

R Corcoran, Jr.
 
Old June 17th, 2004, 07:03 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

I'm unfortunately not familiar to thePhile example. Overloading allows for more than one method with the same name but different parameters to occur. By removing the function, if you are not making a call to it, then it doesn't matter if you remove it. The function returns a data set, which I imagine you use that dataset to bind to the data grid? Then if you are not calling GetAdminVendorEquipment() to get the source for the data set, that method isn't being used.

If you get rid of the other one, you don't need to declare overloads. In VB.NET you don't need to declare overloads actually even if you are.

Speaking of which, if you are still having problems, could you post the code to how you actually bind the dataset to the grid? That will help. Should have asked for that before.

Brian
 
Old June 21st, 2004, 02:43 PM
Authorized User
 
Join Date: Jul 2003
Location: Memphis, TN, USA.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
thanks again...I have deleted the first overloads function
with the 'return...(False)'. This has allowed me to change to
a regular public function for the remaining one...here it is:
<code>
Public Function GetAdminVendorEquipment( _
        ByVal ReceptacleId As Integer) _
        As DataSet

        Dim theAdminVendorEquipment As New Data.VendorEquipment
        (mySettings.ConnectionString)

        Return theAdminVendorEquipment.GetAdminVendorEquipment(
        ReceptacleId, VendorSysId, VendorCompanyName, PropCompanyId,
        PropCompanyName, PropName, LocationDesc)

End Function
</code>
...now I am getting a grid with datarows...but it has a few weird
things I am observing...the binding seems to be one choice behind
when I change the selection in the dropdownlist; and one of the
three test choices I have in the dropdownlist will not post and
bind its items to the grid at all.
I wonder if you (or anyone else) can suggest what I should look at
as the main culprit to see what is causing this...
the code/procedure parts I believe affect the page directly or
through the dropdownlist are:

stproc - GetAdminVendorEquipment
stproc - GetPropCompanyName
datatier - GetAdminVendorEquipment
datatier - GetPropCompanyName
bustier - GetAdminVendorEquipment
bustier - GetPropCompanyName
aspx.vb - PageLoad
aspx.vb - Sub PropCompanyNameList_SelectedItemChanged
aspx.vb - Sub BindGrid

Thx much,

R Corcoran, Jr.
 
Old June 22nd, 2004, 07:21 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Look at Sub PropCompanyNameList_SelectedItemChanged. Post the code, and maybe I can help. Just out of curiosity, what do you need it to do? Is changing on the drop down list undesirable?

Thanks,

Brian
 
Old June 22nd, 2004, 02:14 PM
Authorized User
 
Join Date: Jul 2003
Location: Memphis, TN, USA.
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
here is the code for the 'PropCompanyNameList_SelctedItemChanged'
subroutine:
<code>
Protected Sub PropCompanyNameList_IndexChanged( _
      ByVal sender As Object, _
      ByVal e As EventArgs)

      ' Reload the page to show the Vendor Equipment for the
      selected PropCompanyName

    Response.Redirect(("VendorEquipmentManagement.aspx ?
    PropCompanyId=" & _
    PropCompanyNameList.SelectedItem.Value))

End Sub
</code>

...and to answer your question, it is desireable to have the
grid change (auto-post, in fact) when the selection in the
dropdownlist changes. But what's going wrong is that one of the
three test choices will not post--the grid will not respond
to this choice. And the other two, say choices one and two--
when I select them, the grid is one behind. In other words, when
I choose number one, nothing happens, but then I choose number
two and the grid posts with the datarows for selection #1.

Thanks for looking and let me kow what you think.


R Corcoran, Jr.
 
Old June 23rd, 2004, 01:33 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

When you change the selected items, you don't have to redirect, you can just rebind the data grid:

Protected Sub PropCompanyNameList_IndexChanged( _
      ByVal sender As Object, _
      ByVal e As EventArgs)

datagrid1.datasource = GetAdminVendorEquipment(Integer.Parse(PropCompanyN ameList.SelectedValue)).Tables(0).DefaultView
datagrid1.databind
End Sub

You are one behind probably due to something like you are binding before you are switching the values, or something like that.

Brian




Similar Threads
Thread Thread Starter Forum Replies Last Post
late binding meghaljani BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 6 August 22nd, 2008 07:06 PM
Binding A Variable sirmilt BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 0 February 25th, 2008 02:26 PM
binding arraylist of structures to data grid in C# belzicool General .NET 1 May 9th, 2007 11:58 PM
binding the grid to dataset?? thas123 ASP.NET 2.0 Basics 1 December 27th, 2006 02:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.