I would like to create a nested datalist inside the
selecteditemtem plate of a datalist. My hope is that when a user clicks
on a link a set of child links is displayed. For example if the user
clicks men's clothing he would get a list of sub categories like pants,
shirts, shorts etc
I have put together the following and I get the original datalist fine.
When I try to get the sublist I get the following error: Object
reference not set to an instance of an object.
The offending line is
brandSubList.Da taSource = Catalog.GetSubC atsInBrands(Bra ndID)
from the code behind listed below.
---------------------------------
HTML code looks like this:
<asp:datalist id="brandList" Runat="server">
<ItemTemplate >
<DIV class="navcells "><B>
<asp:hyperlin k id="brandLink" Runat="server" NavigateUrl= '<%#
"../default.aspx?br andID=" & databinder.eval (container.data item,
"strBrandCo de") %>' text= '<%# DataBinder.Eval ( Container.DataI tem,
"strBrandNa me" ) %>' >
</asp:hyperlink></B></DIV>
</ItemTemplate>
<SelectedItemTe mplate>
<asp:DataList id="brandSubLis t" Runat="server">
<ItemTemplate>< DIV class="navcells "><B>
<asp:LinkButt on id="brandsubLin k" Runat="server"
CommandName="se lect"><%# DataBinder.Eval ( Container.DataI tem,
"strSubCategory " ) %>
</asp:LinkButton> </B></DIV>
</ItemTemplate>
</asp:DataList>
</SelectedItemTem plate>
</asp:datalist>
---------------------------------------------------------
My code behind looks like this:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim BrandID As String = Request.QuerySt ring("brandID")
brandList.DataS ource = Catalog.GetBran ds()
brandList.DataB ind()
If Not BrandID Is Nothing Then
Dim BrandSublist As DataList
brandSubList.Da taSource =
Catalog.GetSubC atsInBrands(Bra ndID)
brandSubList.Da taBind()
End If
--------------------------------------------------------
Data is pulled from a business objects doc like this
Public Shared Function GetBrands() As SqlDataReader
'Create connetion objedt
Dim Connection As New SqlConnection(c onnectionString )
'Create and initialize the command Object
Dim command As New SqlCommand("New _GetBrands", Connection)
command.Command Type = CommandType.Sto redProcedure
'Open the connection
Connection.Open ()
'Return a SqlDatatreader
Return command.Execute Reader(CommandB ehavior.CloseCo nnection)
End Function
Public Shared Function GetSubCatsInBra nds(ByVal brandID As String) As
SqlDataReader
'create the connection string
Dim connection As New SqlConnection(c onnectionString )
'Create and initialize the command Object
Dim command As New SqlCommand("New _getSubCatsInBr ands",
connection)
command.Command Type = CommandType.Sto redProcedure
'Add an input parameter and suply a valiue for it
command.Paramet ers.Add("@brand ID", SqlDbType.NVarC har, 5)
command.Paramet ers("@brandID") .Value = brandID
'Open the connection, exectue the command, and clost the
connection
Try
connection.Open ()
command.Execute NonQuery()
Finally
connection.Clos e()
End Try 2 1502
Hello
If you check last few lines of your functions GetSubCatsInBra nds and
GetBrands then you have come to know that in GetBrands after opening
connection
-------------------------------------------------------------------------------------
'Return a SqlDatatreader
Return command.Execute Reader(CommandB ehavior.CloseCo nnection)
-------------------------------------------------------------------------------------
and in function GetSubCatsInBra nds after opening connection
-------------------------------------------------------------------------------------
command.Execute NonQuery()
-------------------------------------------------------------------------------------
So in GetSubCatsInBra nds function It should be Return
command.Execute rReader as writen in GetBrands function.
ExecuteNonQuery will not return recordset it will just execute insert,
delete or update command.
B
Hi, Thanks. I actually realized that and got the datalist working on
it's own. I can properly catch the parameter and the list will work
EXCEPT when it is nested inside another datalist.
Any advice? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: V. Jenks |
last post by:
What seems like a simple thing is apparently not so
straightforward?
I have a datalist.
Inside of that datalist is an <itemtemplate> secion which
contains other server controls such as a label, a
radiobuttonlist, etc.
I'm driving myself insane trying to figure out how to get
|
by: Marty U. |
last post by:
I have two datalists nested. On the ItemDataBound Event of the first
datalist I databind the second with specific info. A couple questions:
1) How can I utilize the OnItemCommand of the nested datalist(inner) to
retrieve the DataKey value when a user clicks a link button?
2) Is there anything I should be concerned with about ViewState? This is
a reporting tool and no input is accepted.
I have found a couple examples but none pointing...
|
by: Derek |
last post by:
I have a nested datalist with a dropdownlist. I need to capture the
selectedvalue of the dropdownlist so I can update a database table. My
question then is...how do I get the value from the nested datalist? Thanks
for any help.
|
by: Chris |
last post by:
I've been searching all over and think I am close, but keep getting the
error "Index out of range" when trying to reference a nested datagrid when
an OnEditCommand event is raised.
When the OnEditCommand event is raised, I try to do the following:
1. Find the selected datalist item in which the nested datagrid raised the
event. (by calling getDataGridReference and returning the DataList's
selectedIndex)
|
by: Martin |
last post by:
Hi,
I have a very frustrating problem that I have researched for countless
hours to no avail. There are many posts asking very similar things,
however none usefull in my situation. I am using VS 2005 (ASP 2.0) and
VB .NET.
I have a page with a datalist, a gridview and then other data controls,
nested in that order. This all works great, and produces a nice looking
page, but I cannot for the life of me figure out how to reference
| |
by: H5N1 |
last post by:
Hi there
My problem is that in when I update GridView row, which is nested into
DataList control, I want to refresh also DataList in which the GridView
is nested, since after update, trigger in my DB changes some value in
it (some Total sum from the GridView column).
The GridView, along with its ObjectDataSource is inserted into DataList
ItemTemplate.
|
by: Les Caudle |
last post by:
I have a menu system composed of a DataList nested inside a DataList.
The outer DataList has it's DataSource (composed of a DataSet with two tables
linked by a CategoryPagesRelation Relation) set in the Page_Load.
The inner DataList has its DataSource set in the ascx file as:
<asp:DataList ID="PageList" runat="server" CellPadding="3" CellSpacing="0"
DataSource='<%#...
|
by: AJ |
last post by:
Hi all,
With the following code in mind :
<asp:DataList ID="dlOne" DataKeyField="myField1" DataSource="<%#
GetDataSource1()" Runat="server">
<ItemTemplate>
Output Value Here!
<asp:DataList ID="dlTwo" DataKeyField="myField2" DataSource="<%#
GetDataSource2(?,?)" Runat="server">
|
by: Ole V.-M. |
last post by:
Greetings,
i have a UserControl, that contains a DataList. That DataList contains
as items other DataLists.
example:
DataList A Row 1
Nested DataList 1
Row 1
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |