How to declare arraylist in dropdownlist , listbox , session

i m creating Album.aspx page but it geting error , How can i declare class veriable and create method in album class  i m pointed my 2 Que below ddalbum_SelectedIndexChanged  

using System;
public partial class Album : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        lbreviewname.Visible = "false";
        lbreviewdetails.Visible = "false";

        if (Session["arrLstItems"] != null)
            lbselectedalbums.DataSource = (ArrayList)Session["arrLstItems"];
            lbselectedalbums.Visible = false;
    protected void btsave_Click(object sender, EventArgs e)
        lbalreadyselected.Text = "";
        lbselectedalbums.Visible = true;
        selected = ddalbum.SelectedItem.Value;

        if (!selected.Equals("Select Album"))
            if (!ChkItemExit())
                lbalreadyselected.Text = "You have already selected this Album";
    protected void ddalbum_SelectedIndexChanged(object sender, EventArgs e)
        lbalreadyselected.Text = "";
        lbreviewname.Visible = true;
        lbreviewdetails.Visible = true;

        if (ddalbum.SelectedItem.Value == "Salute")
            lbreviewdetails.Text = "It is an awsome Album. The music has got lots of variation.";
        else if (ddalbum.SelectedItem.Value == "Drum Circle")
            lbreviewdetails.Text = "This Album is ok. The Music is not that good.";
        else if (ddalbum.SelectedItem.Value == "Death Magnetic")
            lbreviewdetails.Text = "This album is pathetic.";
        else if (ddalbum.SelectedItem.Value == "Black")
            lbreviewdetails.Text = "This album is Good.";
            lbreviewdetails.Text = "";
            lbreviewname.Visible = false;
    /* 1]  Declare the following class variables:
     * ArrayList arrLstItems  = new ArrayList();
     * string Selected */

     /* 2] Create the following methods in the Album class */
   private void AddItemsInSession()
        for (int index = 0; index < lbselectedalbums.Items.Count; index++)
            string strItem = lbselectedalbums.Item[index].Text;
        Session[" arrLstItems"] = arrLstItems;
    private bool ChItemExist()
        string strSelectedItem = ddalbum.SelectedItem.Value;
        bool blRetVal = false;
        for (int index = 0; index < lbselectedalbums.Items.Count; index++)
            string strListItem = lbselectedalbums.Items[index].Text;
            if (string.Compare(strSelectedItem, strLstItem, false) == 0)
                blRetVal = true;

        return blRetVal;
} code Album.aspx Code

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Album.aspx.cs" Inherits="Album" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
        <table class="style1">
                <td align="left" valign="middle">
                    <asp:DropDownList ID="ddalbum" runat="server" 
                     onselectedindexchanged="ddalbum_SelectedIndexChanged" >
                     <asp:ListItem>Select Album</asp:ListItem>
                     <asp:ListItem>Drum Circle</asp:ListItem>
                     <asp:ListItem>Death Magnetic</asp:ListItem>
                      <asp:Button ID="btsave" runat="server" Text="Save"                     onclick="btsave_Click" />
                <td align="left" valign="middle">                    <asp:Label ID="lbreviewname" runat="server" Text="Reviews" Font-Bold="True" 

<asp:Label ID="lbreviewdetails" runat="server" Text="Label"></asp:Label>                    <asp:Label ID="lbalreadyselected" runat="server" Text="Label"></asp:Label>
<asp:Label ID="lbselectedalbum" runat="server" Text="Label"></asp:Label>
                    <br />
                    <br />
<asp:ListBox ID="lbselectedalbums" runat="server"></asp:ListBox>
                </td> </tr>

imu19310 (1)
5/31/2014 7:53:35 AM 29307 articles. 3 followers. Post Follow

0 Replies

Similar Articles

[PageSpeed] 56
Get it on Google Play
Get it on Apple App Store


Similar Artilces:

array vs arraylist vs dropdownlist vs ListBox
I am still learning a lot about I have code where I am loading an sqlObjectReader with multiple field records and i am looking at different ways to parse and store the records I get. So, I am thinking that I would like to use the method, to run through all of the records it has, and to store those records in a different object type. It looks like the dropdownlist, listbox, and arraylist only allow for me to have one item per row, which doesn' t meet what I want. Can I do this with an array ? Or, is there no easy way to add these items dynamically ...

adding a session of listbox items to a new listbox
can someone tell me if it is possible to create a session of listbox items and then populate a new listbox with those items? im guessing when i create the session it should look like this Session("items") = listbox1.Items but then when i try to populate a new listbox with this session it doesnt seem to work im kinda new at this and any help would be appreciated     There can be multiple ways to do this, here are a few: 1. You can store the datasource of the ListBox control in the session and then re-bind the other listbox with the same as: Session("listbox1Data") = l...

Could anyone show me how to add the items from a ListBox to an ArrayList, I know you usally populate a ListBox from an ArrayList but I would like to do the opposite. How's this? 1 // Create the ArrayList 2 ArrayList ddlItems = new ArrayList(); 3 4 // Iterate through each DropDownList item and add its Text to the ArrayList 5 foreach (ListItem item in DropDownListID.Items) 6 ddlItems.Add(item.Text);   Happy Programming!-- Scott Mitchell--

Landing bug 20640 without a full review/super-review
To superreviewers, As some of you may know, I have been working on a major rewrite of the system that packages files for the installers, in order to make the packaging manifests cross-platform and configurable. This work is now complete, but I have been unable to get a full review of all my changes because they are so pervasive (there are many thousands of lines that have been moved from the central packaging manifests to locations throughout the tree). I have been coordinating my efforts with various people to make sure that the build automation process, tinderboxen, and ot...

Dropdownlist as Listbox
I've made my first ASP file which reads data from MSSQL into a dropdownlist, when an item is clicked the details are shown into a gridview. now this all works perfectly though i dont want a dropdownlist. i want it to be just a list (floating on the left) then when an item is clicked it must show on the right (gridview). anyways why cant i get a listbox with links as i have in the dropdown? ohw.. im a newbie to ASP. rostie:anyways why cant i get a listbox with links as i have in the dropdown? you can use "ListBox" instead of Dropdownlist. Are you facing any issue?My Blog...

declare session
Ok, really bad beginner question here:I've been coding all my .Net in Dreamweaver and I'm beginning to look into the VS.Net 2005 Beta. I've created a new web project and added a class file to the project (myClass.vb) within this class I have a sub thats trying to set-up a session variable:   session("mytest") = "hello"However I keep getting an error in my code telling me that the session needs to be declared (line underneath the session part)! I've not had this problem in there something I need to import, or someway I need to reference the session vairable?If I use a s...

how to declare a session variable for two columns and assign gridview1 to the session
 Hello, I have gridview1 on a page that displays reults from a dropdownlist via a sqldatasource. I would like to copy two columns of data from gridview1 and copy them to another gridview1 on another page where I can. I have been reading a lot of articles on the web but, am not sure how to get started declareing a session variable and assigning it so the information can be copied to the next page. Thank you,ptown How about thisOn Page1.aspxprotected void Button1_Click(object sender, EventArgs e){    Session["Value1"] = GridView1.Rows[0].Cells[0].Text; // If you...

arraylist of arraylist
Hi, I'm trying to create arraylist of arraylist as follows: Dim myArr As New ArrayList() myArr.Add(New ArrayList()) myArr(0)(0).add() // The compiler doen't recognize it any suggestions???? Thanks Raviv Casting is required.Dim myArr As New ArrayList myArr.Add(New ArrayList) CType(myArr(0), ArrayList).Add("Element (0)(0)") Response.Write(CType(myArr(0), ArrayList)(0))Picky...

DropDownList Not Declared
Hi All, Please can anyone point me in the right direction here: Any help here would be most apreciated...I wil need an example if possible Compiler Error Message: BC30451: Name 'DropDownList3' is not declared. Source Error: Line 48: Line 49: Line 50: if DropDownList3.SelectedItem.text = "my text" then Line 51: label21.text = "LogNumber" Line 52: end ifAll help appreciatedmany thanksTony What it's telling you is that it can't find a control named DropDownList3 Are you doing this with inline coding or Code Behind?David WierMCP/...

Suppose we have 3 windows : wa1 wa2 inherited from wa1 wa3 inherited from wa2 In wa3 windows, on event pfc_save I override this EVENT and I want to know the return value for pfc_save from wa1 !!! What I mean is ... how can I fire the pfc_save event for wa1 and KNOW the return value of this EVENT ? CALL only fires the EVENT, but id does not return any value of it ! Thanks Hi Stefan, if you are using CALL you can use AncestorReturnValue variable (as far I as I remember it's available since PB6) in order to get the value from your ancestor object. CALL wa1::Event...

DropDownList to DropDownList
I want to take the selected value of DropDownListA and based on that value do a query to the database and populate DropDownListB. For example, DropDownListA contains Entity values. If the user selects entity101 then I call stored procedure where I pass in the entity value, run a select statement and get a list of properties associated with the entity name. I want to take that list and populate DropDownListB. Easy enough to do with ASP.NET using the AutoPostBack. Would be real nice to do this with Atlas. Is it possible? If so, how? Atlas control toolkit has cascading dropdowns-please downlo...

I must be missing something. I can not get the tabs to come back as they were when a session is ended. On the Main tab, I have "Show my windows and tabs from last time" On the Privacy tab, I have "Always clear my private data" with ONLY Download History, Cache, and Authenticated Sessions selected. When I close a session and then restart Firefox, I only get a single blank tab. -- The Frosted Flake +------------------------ SPAM is for eating ------------------------+ Frosted_Flake wrote: > I must be missing something. I can not get the tabs to come...

Relevance of Super-Review (Was: Hardening the review requirements for changing .webidl files)
(I want to avoid entangling the dom/webidl plan with this discussion, which is why I forked the thread) On Thu, Apr 24, 2014 at 3:22 PM, Ehsan Akhgari <>wrote: > Following up on this, people asked us to not abuse the superreview flag for > this purpose If this is "abuse", doesn't that demonstrate that the super-review policy is pretty much irrelevant to the modern world, and should be changed or removed? This rule seems like a textbook use for the sr? flag, aside from the fact that the reviewers must be DOM peers and not peopl...

Request for reviewers and super-reviewers to require more in-code documentation of new code
We've been adding a lot of new code lately, particularly as part of B2G. But we have not been adding high-level in-source documentation along with that code. The result is that it's becoming increasingly difficult to find one's way around our code. To be clear, my beef here isn't so much with a paucity of nitty-gritty comments in implementations about why we do something a particular way, but with the lack of higher-level comments in headers, IDL files, and JS services explaining what a class or interface is used for, how it interacts with other classes, and non-o...

Web resources about - How to declare arraylist in dropdownlist , listbox , session -

Tag Synonyms - Stack Overflow
Q&A for professional and enthusiast programmers

Accidental entities - what about the UI?
This post is a follow-up to my previous blog post " Accidental entities - you don't need that identity ". In that post, we followed a consultant ...

Flash Builder Plug-in for SAP Netweaver Gateway - Adobe Labs
Search Navigation Labs Home Wiki Home Technologies Alchemy Blueprint Camera Profiles and DNG Profile Editor Cirrus ColdFusion 10 DNG Codec Fireworks ...

Air Astana - Join Now
Thank you for considering membership of Nomad Club – Kazakhstan’s first Frequent Flyer Program. You could soon be on your way to earning free ...

Languages -> C# Articles, Tutorials, Examples: ASP Alliance
.NET,ASP,ASP.NET,SQL,XML,HTML,ADO,ADO.NET,JavaScript,JScript,CSharp,VBScript and VB tutorials from AspAlliance.

Blog - Avisra
Avisra Web Development Home Blog Services Contact The Blog Latest Module Builder: How can we make it better? Sitefinity by Chris on July 2, 2013 ...

Online Booking Tool Support
This Online Booking Tool Support page might help you as you navigate through the process of booking travel through your OBT provided by CWT. ...

@Html and beyond
... ); } return string .Format( “{0}{1}” , me.Member.Name, id); } The Html building methods are quite simple. Building a dropdownlist for a ...

Top Ranked Articles
Top Ranked Articles - Free source code and tutorials for Software developers and Architects.; Updated: 23 Feb 2013

Unit Testing DateTime.Now Without Isolation
public virtual void SeedWithYearsSince(DropDownList list, int year){ for (int index = year; index

Resources last updated: 1/19/2016 5:44:53 PM