A dropdownlist problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mathewgk80
    New Member
    • Sep 2007
    • 103

    A dropdownlist problem

    Hi all,
    I am having an aspx page to purchase an item.
    it contains 4 fields..
    1.purchase id(textbox)
    2.product id(dropdownlist )
    3.dateofpurchas e(textbox)
    4.number of items purchased(textb ox)

    if the product id is not available, there is a button in the page to redirect the control to another page to enter the new product details...

    in tht page i have to give product id for the new product.. and other details about new product.

    After entering all the details about a product i have to click on a button which redirects the control to the previous page(purchase).

    i need to get the product id if the new product as the selected item when i load into the purchase page..

    Please help me...

    regards,
    Mathew
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Originally posted by mathewgk80
    Hi all,
    I am having an aspx page to purchase an item.
    it contains 4 fields..
    1.purchase id(textbox)
    2.product id(dropdownlist )
    3.dateofpurchas e(textbox)
    4.number of items purchased(textb ox)

    if the product id is not available, there is a button in the page to redirect the control to another page to enter the new product details...

    in tht page i have to give product id for the new product.. and other details about new product.

    After entering all the details about a product i have to click on a button which redirects the control to the previous page(purchase).

    i need to get the product id if the new product as the selected item when i load into the purchase page..

    Please help me...

    regards,
    Mathew
    Hi Mathew ,

    You're going to need to remember what the selected item was between the pages.


    This means that you're going to have to store the productID somewhere either on the Server or in a Cookie or Hidden field or something.

    If you store this value on the server you'd be using Session...it's pretty easy and will let you remember this information between forms.

    Check out Sessions: How to pass information between web pages for more information.

    Cheers!

    -Frinny

    Comment

    • mathewgk80
      New Member
      • Sep 2007
      • 103

      #3
      Originally posted by Frinavale
      Hi Mathew ,

      You're going to need to remember what the selected item was between the pages.


      This means that you're going to have to store the productID somewhere either on the Server or in a Cookie or Hidden field or something.

      If you store this value on the server you'd be using Session...it's pretty easy and will let you remember this information between forms.

      Check out Sessions: How to pass information between web pages for more information.

      Cheers!

      -Frinny
      Hi Frinny,

      I passed the value of Product Id with the help of Session.. i need to display tht value in the dropdown list as a selected item just after a new product is added....

      Please help me...

      Regards,
      Mathew

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Originally posted by mathewgk80
        Hi Frinny,

        I passed the value of Product Id with the help of Session.. i need to display tht value in the dropdown list as a selected item just after a new product is added....

        Please help me...

        Regards,
        Mathew

        Try this:
        [code=vbnet]
        DDL_MyProductID DropDownList.It ems.FindByValue (Session("Produ ctID")).Selecte d=True
        [/code]

        Comment

        • mathewgk80
          New Member
          • Sep 2007
          • 103

          #5
          Originally posted by Frinavale
          Try this:
          [code=vbnet]
          DDL_MyProductID DropDownList.It ems.FindByValue (Session("Produ ctID")).Selecte d=True
          [/code]
          Hi Frinny,

          Thanks a lot for giving me that code..

          Thanks and Regards,
          Mathew

          Comment

          • mathewgk80
            New Member
            • Sep 2007
            • 103

            #6
            Originally posted by mathewgk80
            Hi Frinny,

            Thanks a lot for giving me that code..

            Thanks and Regards,
            Mathew
            HI Frinny,

            Today i got an Exception in the same program...
            The excepion is:
            "System.Threadi ng.ThreadAbortE xception"

            "Unable to evaluate expression because the code is optimized or a native frame is on the top of the call stack"...

            Please help me to avoid this exception..

            Regards,
            Mathew

            Comment

            • nateraaaa
              Recognized Expert Contributor
              • May 2007
              • 664

              #7
              Are you using a response.Redire ct in your code to go to another page? If so try adding a false after the page like this.

              Response.Redire ct("yourpage.as px", false);

              Let me know if this works or not.

              Nathan

              Comment

              • mathewgk80
                New Member
                • Sep 2007
                • 103

                #8
                Originally posted by nateraaaa
                Are you using a response.Redire ct in your code to go to another page? If so try adding a false after the page like this.

                Response.Redire ct("yourpage.as px", false);

                Let me know if this works or not.

                Nathan
                Hi Nathan..

                The exception is avoided when i give like wht yu have suggested. But I need to pass some values into next page using Session and display tht value in a dropdown list as selected item..

                But i cant be able to do it..

                Please help me...

                The code is as follows..



                SupplierDetails .aspx
                ............... ...............

                Button_click
                ............... ......
                Session["newsupplie rid"] = txtSupplierId.T ext;
                Response.Redire ct("ProductDeta ils.aspx");


                ProductDetails. aspx
                ............... ............... ............... .

                Page_Load
                ............... ...

                String supplierid = Session["newsupplie rid"].ToString();
                DropDownListSup plierID.Items.F indByValue(supp lierid).Selecte d = true;

                Comment

                • nateraaaa
                  Recognized Expert Contributor
                  • May 2007
                  • 664

                  #9
                  Are you getting any errors using Response.Redire ct("yourpage.as px", false)? Is the Session value being lost? What exactly is not working?

                  Make sure that you check your Session variables for null before getting the value of the Session variable.

                  Code:
                  if(Session["supplierId"] != null)
                  {
                  txtSupplierId = Session["supplierId"].ToString();
                  }
                  You know another way to pass information to another page is to use a querystring. A querystring will consume less resources than Session but the drawback is the user can see the information being passed from one page to another in the url.

                  Here is some info on why you were getting the Threading exception.

                  Nathan

                  Comment

                  • mathewgk80
                    New Member
                    • Sep 2007
                    • 103

                    #10
                    Originally posted by nateraaaa
                    Are you using a response.Redire ct in your code to go to another page? If so try adding a false after the page like this.

                    Response.Redire ct("yourpage.as px", false);

                    Let me know if this works or not.

                    Nathan
                    Hi Nathan..

                    The exception is avoided when i give like wht yu have suggested. But I need to pass some values into next page using Session and display tht value in a dropdown list as selected item..

                    But i cant be able to do it..

                    Please help me...

                    The code is as follows..



                    SupplierDetails .aspx
                    ............... ...............

                    Button_click
                    ............... ......
                    Session["newsupplie rid"] = txtSupplierId.T ext;
                    Response.Redire ct("ProductDeta ils.aspx");


                    ProductDetails. aspx
                    ............... ............... ............... .

                    Page_Load
                    ............... ...

                    String supplierid = Session["newsupplie rid"].ToString();
                    DropDownListSup plierID.Items.F indByValue(supp lierid).Selecte d = true;

                    Comment

                    • nateraaaa
                      Recognized Expert Contributor
                      • May 2007
                      • 664

                      #11
                      You already replied with that answer. Why are you saying that the code does not work? Does the page not redirect? Is the Session value lost? Some other problem occurring.

                      Nathan

                      Comment

                      Working...