By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,679 Members | 2,469 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,679 IT Pros & Developers. It's quick & easy.

Cascaded menus and multi-select CheckBoxList

P: n/a
There are three parts to this

1.) How do I cascade menus?

2.) And, how do I cascade menus with a multi-select CheckBoxList?

3.) How do I default to all? When no items are selected. (I know how to
detect no box selected . I just don't know how to 'lose' the where statement
if no list box is selected.)

Here are the select statements;

The query for the first menu

select usr ,grpId

from tblgrp

The query for the second menu

select car, carId

from tblCars

where grpI in (@grpId)

Please answer questions 1, 2 and 3.

Thank you,

Doug
Jun 27 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi Doug,

Regarding on the questionsa bout the Menu control, I'd like to confirm some
further things:

1)As for cascading the menu control, do you mean you want to display data
via Menu control and make menu items displayed in different layers? If so,
based on my research, the menu control does support multiple level
menuitems display. And so far there are several means to populate menu
items:

i. use code to programmtically populate the Menu control's Menu items
collection
ii. use databindings setting, and a very common approad is supply a xml
datasource which can map different xml element at different menu level.

#Populating Menu Control in ASP.NET 2.0 - using different data sources
http://www.codeproject.com/KB/menus/...ntrolASP2.aspx

http://quickstart.developerfusion.co...ctrlref/naviga
tion/menu.aspx

Also, for your scenario, it quite depend on your datasource(what are the
original data structure) which will impact how we can associate it with the
menu control
2)And, how do I cascade menus with a multi-select CheckBoxList?
======================
I'm still a bit unclear about this, are you using checkboxlist inside menu
template or would you further clarity how you currrently integrated
checkboxlist with menu control?

3)How do I default to all? When no items are selected. (I know how to
detect no box selected . I just don't know how to 'lose' the where
statement
if no list box is selected.)
============================
for this question, I'm wondering how do you currently execute the select
statement, are you directly execute it via ADO.NET code or use a SQL
DataSource control?

*If using ADO.NET code, I think you can explicitly check whether there is
no item selected and change to use a non-where select statement for that
case.

*If you are using SqlDatasource control. One approach I can think is
putting two different data source control on page(one of them always return
all the records) and you can programmtically assign the proper one to the
Menu or databound control(depend on whether there is element selected).

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: "dbuchanan" <db*******@newsgroup.nospam>
Subject: Cascaded menus and multi-select CheckBoxList
Date: Wed, 4 Jun 2008 08:20:40 -0400
>There are three parts to this

1.) How do I cascade menus?

2.) And, how do I cascade menus with a multi-select CheckBoxList?

3.) How do I default to all? When no items are selected. (I know how to
detect no box selected . I just don't know how to 'lose' the where
statement
>if no list box is selected.)

Here are the select statements;

The query for the first menu

select usr ,grpId

from tblgrp

The query for the second menu

select car, carId

from tblCars

where grpI in (@grpId)

Please answer questions 1, 2 and 3.

Thank you,

Doug
Jun 27 '08 #2

P: n/a
Steven,

I am sorry, my choice of words was bad. Instead of *menu* I should have said
*control*.

What I am trying to do is have the first of two controls filter what is
displayed in the second control.

For example if in the first CheckBoxList (multi-select) the user selects
'NorthEast' and 'SouthWest' regions then the second CheckBoxList
(multi-select) will display 'Maine', 'New York', 'Nevada' and 'New Mexico'
but will not display 'Oregon' or 'Florida' becuase they are in the
'NorthWest' and 'SouthEast" which were not selected in the first
CheckBoxList.

1.) How do I have the first control supply the parameters for the second
control? I am looking for a good explaination because I am new to aspx. A
link to a very good walk-through - if it is good - would be nice.

Up to now I had set up my controls by using a SqlDataSource. This time I
tried to set my control by putting my queries in a tableAdapter insid my
XSD. While doing this I noticed functionality for setting up parameters. I
would guess thia is how I would set up one contro to be dependant upon
another.

BUT... ( and before setting up parameters)

I tried to run the project to see the controls populate. Instead it crashed
with the error below.

2.) What could I have done wrong?

Thank you,
Doug

=== starr of error ==============
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:
Line 931: this.Adapter.SelectCommand = this.CommandCollection[0];
Line 932: if ((this.ClearBeforeFill == true)) {
Line 933: dataTable.Clear();
Line 934: }
Line 935: int returnValue = this.Adapter.Fill(dataTable);
Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET
Files\websiterlftirekingdomcoursecompletionreport\ 7697443b\2ec251ca\App_Code.9o1brfaa.0.cs
Line: 933

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
ControlsDataSetTableAdapters.CourseGroupsTableAdap ter.FillSelectCourseGroups(CourseGroupsDataTable
dataTable) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary
ASP.NET
Files\websiterlftirekingdomcoursecompletionreport\ 7697443b\2ec251ca\App_Code.9o1brfaa.0.cs:933

[TargetInvocationException: Exception has been thrown by the target of an
invocation.]
System.RuntimeMethodHandle._InvokeMethodFast(Objec t target, Object[]
arguments, SignatureStruct& sig, MethodAttributes methodAttributes,
RuntimeTypeHandle typeOwner) +0
System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[]
arguments, Signature sig, MethodAttributes methodAttributes,
RuntimeTypeHandle typeOwner) +72
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean
skipVisibilityChecks) +358
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +29
System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +17
System.Web.UI.WebControls.ObjectDataSourceView.Inv okeMethod(ObjectDataSourceMethod
method, Boolean disposeInstance, Object& instance) +676
System.Web.UI.WebControls.ObjectDataSourceView.Exe cuteSelect(DataSourceSelectArguments
arguments) +2664
System.Web.UI.WebControls.ListControl.OnDataBindin g(EventArgs e) +65
System.Web.UI.WebControls.ListControl.PerformSelec t() +32
System.Web.UI.WebControls.BaseDataBoundControl.Dat aBind() +99
System.Web.UI.WebControls.BaseDataBoundControl.Ens ureDataBound() +92
System.Web.UI.WebControls.BaseDataBoundControl.OnP reRender(EventArgs e)
+33
System.Web.UI.WebControls.ListControl.OnPreRender( EventArgs e) +31
System.Web.UI.WebControls.CheckBoxList.OnPreRender (EventArgs e) +38
System.Web.UI.Control.PreRenderRecursiveInternal() +148
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4436


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET
Version:2.0.50727.832
=== end of error ==============

Jun 27 '08 #3

P: n/a
Hi Doug,

If you're not quite familar with ASP.NET Data Access and DataBound control
model, I suggest you have a look at the Data Access tutorial on ASP.NET
official site:

#Data Access Tutorials
http://www.asp.net/learn/data-access/

the tutorial contains many very good and typical samples.

Also, for your scenario, since your second control's datasource(result set)
will rely on the first control(checkboxlist's selected items). I would
suggest you manually use code to check all the selected items in the first
CheckBoxList control e.g.

============
foreach (ListItem item in CheckBoxList1.Items)
{
if(item.Selected == true)
//append to query parameter
}
============

After that, you also programmtically use ADO.NET SqlCommand to execute
command and get the DataReader or DataSet and bind it to DataGrid/Gridview
control. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "dbuchanan" <db*******@newsgroup.nospam>
References: <uj**************@TK2MSFTNGP03.phx.gbl>
<g5**************@TK2MSFTNGHUB02.phx.gbl>
>Subject: Re: Cascaded menus and multi-select CheckBoxList
Date: Thu, 5 Jun 2008 02:30:33 -0400
>Steven,

I am sorry, my choice of words was bad. Instead of *menu* I should have
said
>*control*.

What I am trying to do is have the first of two controls filter what is
displayed in the second control.

For example if in the first CheckBoxList (multi-select) the user selects
'NorthEast' and 'SouthWest' regions then the second CheckBoxList
(multi-select) will display 'Maine', 'New York', 'Nevada' and 'New Mexico'
but will not display 'Oregon' or 'Florida' becuase they are in the
'NorthWest' and 'SouthEast" which were not selected in the first
CheckBoxList.

1.) How do I have the first control supply the parameters for the second
control? I am looking for a good explaination because I am new to aspx. A
link to a very good walk-through - if it is good - would be nice.

Up to now I had set up my controls by using a SqlDataSource. This time I
tried to set my control by putting my queries in a tableAdapter insid my
XSD. While doing this I noticed functionality for setting up parameters. I
would guess thia is how I would set up one contro to be dependant upon
another.

BUT... ( and before setting up parameters)

I tried to run the project to see the controls populate. Instead it
crashed
>with the error below.

2.) What could I have done wrong?

Thank you,
Doug

=== starr of error ==============
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:
Line 931: this.Adapter.SelectCommand =
this.CommandCollection[0];
>Line 932: if ((this.ClearBeforeFill == true)) {
Line 933: dataTable.Clear();
Line 934: }
Line 935: int returnValue = this.Adapter.Fill(dataTable);
Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary
ASP.NET
>Files\websiterlftirekingdomcoursecompletionreport \7697443b\2ec251ca\App_Cod
e.9o1brfaa.0.cs
>Line: 933

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
ControlsDataSetTableAdapters.CourseGroupsTableAdap ter.FillSelectCourseGroups
(CourseGroupsDataTable
>dataTable) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary
ASP.NET
Files\websiterlftirekingdomcoursecompletionreport \7697443b\2ec251ca\App_Cod
e.9o1brfaa.0.cs:933
>
[TargetInvocationException: Exception has been thrown by the target of an
invocation.]
System.RuntimeMethodHandle._InvokeMethodFast(Objec t target, Object[]
arguments, SignatureStruct& sig, MethodAttributes methodAttributes,
RuntimeTypeHandle typeOwner) +0
System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[]
arguments, Signature sig, MethodAttributes methodAttributes,
RuntimeTypeHandle typeOwner) +72
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture,
Boolean
>skipVisibilityChecks) +358
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +29
System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +17
System.Web.UI.WebControls.ObjectDataSourceView.Inv okeMethod(ObjectDataSource
Method
>method, Boolean disposeInstance, Object& instance) +676
System.Web.UI.WebControls.ObjectDataSourceView.Exe cuteSelect(DataSourceSelec
tArguments
>arguments) +2664
System.Web.UI.WebControls.ListControl.OnDataBindin g(EventArgs e) +65
System.Web.UI.WebControls.ListControl.PerformSelec t() +32
System.Web.UI.WebControls.BaseDataBoundControl.Dat aBind() +99
System.Web.UI.WebControls.BaseDataBoundControl.Ens ureDataBound() +92
System.Web.UI.WebControls.BaseDataBoundControl.OnP reRender(EventArgs e)
+33
System.Web.UI.WebControls.ListControl.OnPreRender( EventArgs e) +31
System.Web.UI.WebControls.CheckBoxList.OnPreRender (EventArgs e) +38
System.Web.UI.Control.PreRenderRecursiveInternal() +148
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4436


---------------------------------------------------------------------------
-----
>Version Information: Microsoft .NET Framework Version:2.0.50727.832;
ASP.NET
>Version:2.0.50727.832
=== end of error ==============

Jun 27 '08 #4

P: n/a
Hi Doug,

Have you got any progress or does my further suggetion help you some?

Please feel free to let me know if there is anything else we can help.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: st*****@online.microsoft.com (Steven Cheng [MSFT])
Organization: Microsoft
Date: Fri, 06 Jun 2008 07:28:22 GMT
Subject: Re: Cascaded menus and multi-select CheckBoxList
>Hi Doug,

If you're not quite familar with ASP.NET Data Access and DataBound control
model, I suggest you have a look at the Data Access tutorial on ASP.NET
official site:

#Data Access Tutorials
http://www.asp.net/learn/data-access/

the tutorial contains many very good and typical samples.

Also, for your scenario, since your second control's datasource(result
set)
>will rely on the first control(checkboxlist's selected items). I would
suggest you manually use code to check all the selected items in the first
CheckBoxList control e.g.

============
foreach (ListItem item in CheckBoxList1.Items)
{
if(item.Selected == true)
//append to query parameter
}
============

After that, you also programmtically use ADO.NET SqlCommand to execute
command and get the DataReader or DataSet and bind it to DataGrid/Gridview
control. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

================================================= =
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ault.aspx#noti
f
>ications.

================================================= =
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>>From: "dbuchanan" <db*******@newsgroup.nospam>
References: <uj**************@TK2MSFTNGP03.phx.gbl>
<g5**************@TK2MSFTNGHUB02.phx.gbl>
>>Subject: Re: Cascaded menus and multi-select CheckBoxList
Date: Thu, 5 Jun 2008 02:30:33 -0400
>>Steven,

I am sorry, my choice of words was bad. Instead of *menu* I should have
said
>>*control*.

What I am trying to do is have the first of two controls filter what is
displayed in the second control.

For example if in the first CheckBoxList (multi-select) the user selects
'NorthEast' and 'SouthWest' regions then the second CheckBoxList
(multi-select) will display 'Maine', 'New York', 'Nevada' and 'New
Mexico'
>>but will not display 'Oregon' or 'Florida' becuase they are in the
'NorthWest' and 'SouthEast" which were not selected in the first
CheckBoxList.

1.) How do I have the first control supply the parameters for the second
control? I am looking for a good explaination because I am new to aspx. A
link to a very good walk-through - if it is good - would be nice.

Up to now I had set up my controls by using a SqlDataSource. This time I
tried to set my control by putting my queries in a tableAdapter insid my
XSD. While doing this I noticed functionality for setting up parameters.
I
>>would guess thia is how I would set up one contro to be dependant upon
another.

BUT... ( and before setting up parameters)

I tried to run the project to see the controls populate. Instead it
crashed
>>with the error below.

2.) What could I have done wrong?

Thank you,
Doug

=== starr of error ==============
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not
set
>>to an instance of an object.

Source Error:
Line 931: this.Adapter.SelectCommand =
this.CommandCollection[0];
>>Line 932: if ((this.ClearBeforeFill == true)) {
Line 933: dataTable.Clear();
Line 934: }
Line 935: int returnValue = this.Adapter.Fill(dataTable);
Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary
ASP.NET
>>Files\websiterlftirekingdomcoursecompletionrepor t\7697443b\2ec251ca\App_Co
d
>e.9o1brfaa.0.cs
>>Line: 933

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
ControlsDataSetTableAdapters.CourseGroupsTableAda pter.FillSelectCourseGroup
s
>(CourseGroupsDataTable
>>dataTable) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary
ASP.NET
Files\websiterlftirekingdomcoursecompletionrepor t\7697443b\2ec251ca\App_Co
d
>e.9o1brfaa.0.cs:933
>>
[TargetInvocationException: Exception has been thrown by the target of an
invocation.]
System.RuntimeMethodHandle._InvokeMethodFast(Objec t target, Object[]
arguments, SignatureStruct& sig, MethodAttributes methodAttributes,
RuntimeTypeHandle typeOwner) +0
System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[]
arguments, Signature sig, MethodAttributes methodAttributes,
RuntimeTypeHandle typeOwner) +72
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture,
Boolean
>>skipVisibilityChecks) +358
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +29
System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
+17
>>
System.Web.UI.WebControls.ObjectDataSourceView.In vokeMethod(ObjectDataSourc
e
>Method
>>method, Boolean disposeInstance, Object& instance) +676
System.Web.UI.WebControls.ObjectDataSourceView.Ex ecuteSelect(DataSourceSele
c
>tArguments
>>arguments) +2664
System.Web.UI.WebControls.ListControl.OnDataBindin g(EventArgs e) +65
System.Web.UI.WebControls.ListControl.PerformSelec t() +32
System.Web.UI.WebControls.BaseDataBoundControl.Dat aBind() +99
System.Web.UI.WebControls.BaseDataBoundControl.Ens ureDataBound() +92
System.Web.UI.WebControls.BaseDataBoundControl.OnP reRender(EventArgs
e)
>>+33
System.Web.UI.WebControls.ListControl.OnPreRender( EventArgs e) +31
System.Web.UI.WebControls.CheckBoxList.OnPreRender (EventArgs e) +38
System.Web.UI.Control.PreRenderRecursiveInternal() +148
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4436


--------------------------------------------------------------------------
-
>-----
>>Version Information: Microsoft .NET Framework Version:2.0.50727.832;
ASP.NET
>>Version:2.0.50727.832
=== end of error ==============


Jun 27 '08 #5

P: n/a
Steve,

Your direction and link excellent.

Thank you,
Doug
Jun 27 '08 #6

P: n/a
Thanks for your reply Doug,

I'm glad that the suggestion help you.

Have a nice day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "dbuchanan" <db*******@newsgroup.nospam>
Subject: Re: Cascaded menus and multi-select CheckBoxList
Date: Tue, 10 Jun 2008 23:03:20 -0400
>
Steve,

Your direction and link excellent.

Thank you,
Doug
Jun 27 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.