CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 2/23/2004 2:30:57 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 2 Views: 12 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
3 Items, 1 Pages 1 |< << Go >> >|
MrCarl
Asp.Net User
MyFirstControl... Not working :( Please help!!2/23/2004 2:30:57 PM

0/0

Hi All,

I have wrote a control which just outputs some javascript to an ASP:Literal control. But its throwing up an error, the control compiled ok but when the ASP.NET page runs I get this error on Line 10:

Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: dataSet


Source Error:

Line 8: objNavigation.Groups = "2,3"
Line 9: objNavigation.Target = "content"
Line 10: litJavaScript.Text = objNavigation.WriteNavigation()
Line 11:
Line 12: End Sub


Now the code I used in the control worked fine when out on a normal asp.net page, but as soon as it was placed in a class it started playing up. Any Ideas?? Here is the code for the class.

Thanks ppl...


Imports System
Imports System.Xml
Imports System.Data
Imports System.Data.SqlClient

Namespace Cienet

Public Class Navigation

Public Sub New()
End Sub

' Declare property variables
Private _strGroups as String
Private _strTarget as String

' Declare class variables
Private _intCounter as Integer
'Private _sbJavaScript As New StringBuilder()

Public WriteOnly Property Groups as String
Set (ByVal strGroups as String)
_strGroups = strGroups
End Set
End Property

Public WriteOnly Property Target as String
Set (ByVal strTarget as String)
_strTarget = strTarget
End Set
End Property

Public Function WriteNavigation()

Dim objSqlConnection as New SqlConnection("server='******'; user id='******'; password='********'; database='*****'")

Dim objNavDataSet as DataSet

' Create DataAdapter for Navigation Groups
Dim objNavGroupsSqlCommand as New SqlCommand("spNavGroups", objSqlConnection)
objNavGroupsSqlCommand.CommandType = CommandType.StoredProcedure
objNavGroupsSqlCommand.Parameters.Add("@strNavGroups", SqlDbType.VarChar, 255).Value = _strGroups
Dim objNavGroupsDataAdapter as New SqlDataAdapter(objNavGroupsSqlCommand)

objSqlConnection.Open()

objNavGroupsDataAdapter.Fill(objNavDataSet, "tblNavGroups")

' Loop through group rows to generate where SQL for items
Dim objNavGroupsDataRow as DataRow
Dim strNavItemsSqlWhere as String
Dim intCounter as Integer = 0

For Each objNavGroupsDataRow in objNavDataSet.Tables("tblNavGroups").Rows
If intCounter <> 0 Then strNavItemsSqlWhere = strNavItemsSqlWhere & ","
strNavItemsSqlWhere = strNavItemsSqlWhere & objNavGroupsDataRow.Item("strItems").ToString()
intCounter = intCounter + 1
Next

' Create DataAdapter for Navigation Items
Dim objNavItemsSqlCommand as New SqlCommand("spNavItems", objSqlConnection)
objNavItemsSqlCommand.CommandType = CommandType.StoredProcedure
objNavItemsSqlCommand.Parameters.Add("@strNavItems", SqlDbType.VarChar, 255).Value = strNavItemsSqlWhere
Dim objNavItemsDataAdapter as New SqlDataAdapter(objNavItemsSqlCommand)

objNavItemsDataAdapter.Fill(objNavDataSet, "tblNavItems")

' Close DB Conn
objSqlConnection.Close()

' Start generating JavaScript for menu
Dim objNavItemsDataRow as DataRow
Dim strJavaScript as String
intCounter = 0

' Loop through each NavGroup
For Each objNavGroupsDataRow in objNavDataSet.Tables("tblNavGroups").Rows

strJavaScript = strJavaScript & "Link[" & intCounter & "] = ""0|" & objNavGroupsDataRow.Item("strGroupName").ToString() & "||"";"

intCounter = intCounter + 1

' Create DataView to query what NavItems are needed
Dim objNavItemsDataView as DataView = objNavDataSet.Tables("tblNavItems").DefaultView
objNavItemsDataView.RowFilter = "idNavItem IN (" & objNavGroupsDataRow.Item("strItems").ToString() & ")"
Dim objNavItemsDataRowView As DataRowView

' Loop through NavItems
For Each objNavItemsDataRowView In objNavItemsDataView

strJavaScript = strJavaScript & "Link[" & intCounter & "] = ""1|" & objNavItemsDataRowView.Item("strItemName").ToString() & "|" & objNavItemsDataRowView.Item("strLink").ToString() & "|" & objNavItemsDataRowView.Item("strTarget").ToString() & """;"
intCounter = intCounter + 1

Next

Next

Return strJavaScript

End Function

End Class

End Namespace



MrCarl
Asp.Net User
Re: MyFirstControl... Not working :( Please help!!2/23/2004 5:13:52 PM

0/0

Arrghhh!! THis error is really bugging me now!! hehe... Please help...

Ive worked out that its this line which is throwing the error:

objNavGroupsDataAdapter.Fill(objNavDataSet, "tblNavGroups")

I dont understand though because the stored procedures and everything worked fine when this code was outside of the class and on the asp.net page itself. Its just bringing up errors now its in a class.

Am I importing the right things at the top of the page?? see im worried because im very new to this!!

Thanks

- Carl S
MrCarl
Asp.Net User
Re: MyFirstControl... Not working :( Please help!!2/23/2004 5:21:26 PM

0/0

Grrrrrrrrrrrrr!!!! FOr anyone thats read this its fixed now...

Was simply this:

Dim objNavDataSet as DataSet

Needed to be this:

Dim objNavDataSet as New DataSet

Doh!!!!!!!!!!!!!!!!!! Bit of a Homer Simpson moment :)
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
Handle Event of Dynamically Added User Control myFirstControl fires LinkClicked event and I don't know how to handle that LinkClicked event from containing page. Please help!! Thanks! ...
Application.LoadComponent() problems June CTP -> RC1 If not, please give me the specific scenario where it falls down with ... In this project there's a new control that inherit from MyFirstControl. ...
reusing Panel - Ext JS Forums i have tried giving a unique id to the new instances that i created that also did not help me out. Can any one tell me what i am doing wrong ...
Windows Client, Windows Forms, Windows Presentation Foundation I can not apply multi transform to Canvas' RenderTransform property one time. Please help me to do it soon... Thanks,. Posted May 08 2006, 03:55 AM by MSDN ...
Mail reader Please note that this does not remove the state of the ResMgr itself, so access to a ... Dialog( MyModResId( MY_DIALOG_RESOURCE_ID ), myFirstControl( this, ...
blog.anthonyburns.co.uk After a quick google I found a list of words designed to help people play .... 7 : alert('A file is currently being uploaded, please wait for it to finish ...
3.0.12 Gallery and content type - ng.asp-net-forum.dotnetnuke ... myfirstcontrol... not working :( please help!! dnn 3.0.13 installation - missing stored procedure???? running a .net timer on page load ...
TheMSsForum.com >> Asp >> Is it possible to change culture at ... Dim myUserControl as Object = LoadControl("myFirstControl.ascx") .... Please help if you can. Thanks in advance!! Class: Public Class anEvent Public ...




Search This Site:










what is "updateable query"?

using server.execute

customize password recovery control

customer satisfaction survey

missing user controls

loggin/out impossible

custom methods

authentication error??

leveraging wmi with asp.net

webservices

problems with objects

tabstrip in vs2005 now firefox compatible?

dnn broke 100,000 registrations !!!

asp._default_aspx.frameworkinitialize()': no suitable method found to override

plus (+)-character in params?

positioning of control

how do i install dnn 3.1.1?

download error of source code 3.0.8

can't get to dotnetnuke from anywhere bar the host server!!!

automated and random slideshow using vb.net, vs2003 and database

treeview display problems .. nodes not aligned

personal site with access db

help needed on letting user select his/her own role while creating account

generating webparts programmatically

change child portal to parent portal.

nested controls and onclick event handling

load a pdf into browser via database not as a cached link?

care and feeding of dnn

2 simple question

remote control

 
All Times Are GMT