473,378 Members | 1,482 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

A dropdownlist problem

103 100+
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.dateofpurchase(textbox)
4.number of items purchased(textbox)

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
Oct 31 '07 #1
10 1230
Frinavale
9,735 Expert Mod 8TB
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.dateofpurchase(textbox)
4.number of items purchased(textbox)

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
Oct 31 '07 #2
mathewgk80
103 100+
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
Oct 31 '07 #3
Frinavale
9,735 Expert Mod 8TB
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:
Expand|Select|Wrap|Line Numbers
  1. DDL_MyProductIDDropDownList.Items.FindByValue(Session("ProductID")).Selected=True
  2.  
Oct 31 '07 #4
mathewgk80
103 100+
Try this:
Expand|Select|Wrap|Line Numbers
  1. DDL_MyProductIDDropDownList.Items.FindByValue(Session("ProductID")).Selected=True
  2.  
Hi Frinny,

Thanks a lot for giving me that code..

Thanks and Regards,
Mathew
Oct 31 '07 #5
mathewgk80
103 100+
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.Threading.ThreadAbortException"

"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
Nov 1 '07 #6
nateraaaa
663 Expert 512MB
Are you using a response.Redirect in your code to go to another page? If so try adding a false after the page like this.

Response.Redirect("yourpage.aspx", false);

Let me know if this works or not.

Nathan
Nov 1 '07 #7
mathewgk80
103 100+
Are you using a response.Redirect in your code to go to another page? If so try adding a false after the page like this.

Response.Redirect("yourpage.aspx", 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["newsupplierid"] = txtSupplierId.Text;
Response.Redirect("ProductDetails.aspx");


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

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

String supplierid = Session["newsupplierid"].ToString();
DropDownListSupplierID.Items.FindByValue(supplieri d).Selected = true;
Nov 1 '07 #8
nateraaaa
663 Expert 512MB
Are you getting any errors using Response.Redirect("yourpage.aspx", 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.

Expand|Select|Wrap|Line Numbers
  1. if(Session["supplierId"] != null)
  2. {
  3. txtSupplierId = Session["supplierId"].ToString();
  4. }
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
Nov 1 '07 #9
mathewgk80
103 100+
Are you using a response.Redirect in your code to go to another page? If so try adding a false after the page like this.

Response.Redirect("yourpage.aspx", 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["newsupplierid"] = txtSupplierId.Text;
Response.Redirect("ProductDetails.aspx");


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

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

String supplierid = Session["newsupplierid"].ToString();
DropDownListSupplierID.Items.FindByValue(supplieri d).Selected = true;
Nov 1 '07 #10
nateraaaa
663 Expert 512MB
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
Nov 1 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Brennon Arnold | last post by:
I have a problem that I figured would be relatively common, but have been unable to find any information on it as of yet. I have a page that contains two DropDownList controls, with the second...
12
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option...
2
by: Antonio D'Ottavio | last post by:
Good Morning, In my web page I've a datalist that is sourced by a database, the problem is that I want that one of the column of the datalist contain a dropdownbox that also is sourced by a table...
1
by: Antonio D'Ottavio | last post by:
Good morning, I've a problem with a dropdownlist located inside any row of a datalist, I fill both datalist and dropdownlist at runtime, the problem is with the dropdownlist infact using the event...
10
by: dhnriverside | last post by:
Hi guys Still having a problem with this dropdownlist. Basically, I've got 4. The first 2 work fine, then my code crashes on the 3rd. ddlEndTimeHour.Items.FindByValue(endTime).Selected =...
4
by: Mark Waser | last post by:
I've discovered a very odd bug when attempting to put a dropdown list in a datagrid. In the page PreRender step, the selected index of the datagrid is successfully set during databinding. Yet,...
0
by: Juanjo | last post by:
Hi, Before, I was working with Asp.net 1.0 and datagrid. I posted a question for this issue. The solution of this problem is load the second dropdownlist on the selectedindexchanged event of the...
3
by: Lohboy | last post by:
Using ASP.NET and IE7. (Sorry if I am posting in the wrong forum but my problem seemed to be more related to the JavaScript side than the ASP.NET side.) I have two DropDownList controls the...
1
by: Brett | last post by:
I have a DropDownList in an ASP.NET web form that is populated with items from a lookup table by binding that DropDownList to a SqlDataSource. However, the items in the lookup table can change over...
6
by: shashi shekhar singh | last post by:
Respected Sir, I have to create multiple dynamic dropdownlist boxes and add items dynamically in <asp:table> server control but problem occurs , i.e. except of fist dropdown list no dropdownlist...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.