Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 5th, 2007, 09:42 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dropdown list with multiple selections

hi all,

I have a small problem. Let me explain my situation first. I am making a website with a ms sql database. In the backend of my site i have some kind of an user administration.
The user is selected by a listbox what opens a detailsview with all user data (username, password, level etc) also there is a website admin where i can add websites (websitename, url etc)
My problem:
I want to have a listbox in this detailsview also, connect 1 user to 1 OR more websites. Therefor i made a 3rd table what contains the userid an websiteid(this user can edit multiple website so for each website there wil be a new record)
This list has an own sqldatasource as source(the website table). This already works but i want to select the websites that are connected to this user how can i do this?


The List (stands in a <asp:templatefield> within the detailsview)
Code:
<asp:ListBox runat="server" ID="lstWebsites" SelectionMode="Multiple" DataSourceID="websites" DataTextField="website_name" DataValueField="website_id"></asp:ListBox>
The sqlDatasource:
Code:
<asp:SqlDataSource ID="websites" runat="server" ConnectionString="<%$ ConnectionStrings:BugLoggerConnectionString %>" 
SelectCommand="SELECT website_id, website_name, (SELECT website_id FROM l_user_website  WHERE  website_id = w.website_id AND user_id = @user_id) AS edit FROM website w WHERE (deleted = 0)">
  <SelectParameters>
    <asp:ControlParameter ControlID="lst_Users" Name="user_id" Type="Decimal" />
    <asp:Parameter DefaultValue="false" Name="deleted" Type="Boolean" />     
  </SelectParameters>      
</asp:SqlDataSource>
  #2 (permalink)  
Old March 5th, 2007, 09:55 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I don't understand what you are asking, however, based on the title of your Post, a dropdownlist CANNOT have multiple selections within the list a listbox, however, can.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
  #3 (permalink)  
Old March 5th, 2007, 09:57 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

im sorry as you can see in the first codeblock i am using a listbox

  #4 (permalink)  
Old March 5th, 2007, 10:00 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Yes i see that. And, as I said, I based that response on the title of your post. In any case, you have not made it anymore clear to me as to what you are trying to accomplish??

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
  #5 (permalink)  
Old March 5th, 2007, 10:10 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

pff to bad. its hard enough for my to try to explain my problem :)
but here i go:

what i want is a listbox wich contains all the websites. And the websites that are connected to the selected user must be selected.
i can make this outside the detailsview and do the binding in the page_load by using a loop of something but that is not very practical. i want to try to make this without any codebehind code but i dont realy know if this is possible.

hope this clear it up a little

  #6 (permalink)  
Old March 5th, 2007, 10:17 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Doing it w/o code behind is not going to be probable if not impossible (I think).

Couple of things you may want to consider:

Handle the item onChanged event of the dropdown and pass the selected item of the dropdown into a stored procedure to return that particular users websites and populate the list box based on the values that are returned.

You may also want to consider looking into Data Relation, however, I don't have much experience using data relation with Datasets and such, but it may be a viable option for you.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
  #7 (permalink)  
Old March 5th, 2007, 11:13 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i have got this now in my page_load:
Code:
  If lst_Users.SelectedValue > 0 Then
            Dim lst As ListBox = CType(Me.User_detail.FindControl("lstWebsites"), ListBox)
            Dim id
            Dim dt As ds_user.userDataTable = bl.getUserWebsites(lst_Users.SelectedValue)
            Dim sel As ds_user.userRow
            For Each sel In dt
                id = sel("website_id").ToString
                lst.Items.FindByValue(id).Selected = True
            Next
        End If

it returns a table with website_id's wich have to be selected. The first time the page
loads this works just fine but when i select an other user none of the items in the list
wil be selected. There is at least 1 website to be selected. but it doesnt. When i use
a break point the code wil go through the loop but still none of the websites is selected.
how is this possible?

  #8 (permalink)  
Old March 5th, 2007, 11:27 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You don't set any values to be selected in code?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
  #9 (permalink)  
Old March 5th, 2007, 11:29 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

nope only there

  #10 (permalink)  
Old March 5th, 2007, 11:36 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

hmmm I am not really sure what is going on with this. Though I may change my condition to

  If lst_Users.SelectedIndex > -1 Then

Of course that doesn't explain why your loop executes and no items are selected, of course, I would say that when you do your finditem the runtime doesn't see the value you are looking for or it doesnt exist.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DropDown list selections with IE Back button Dawn_B ASP.NET 1.0 and 1.1 Basics 0 May 3rd, 2006 11:57 AM
C# ListBox Working With Multiple Selections pro-logic C# 1 October 9th, 2005 02:15 AM
Select Menu Multiple Selections phungleon HTML Code Clinic 2 July 20th, 2004 12:25 PM
Storing multiple values from the dropdown list lily611 SQL Server 2000 0 June 21st, 2004 06:08 AM
Storing multiple values from the dropdown list lily611 ADO.NET 0 June 21st, 2004 05:21 AM



All times are GMT -4. The time now is 01:55 PM.


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