.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Retain DropDown,TextBox's previously selected values after redirected from another page.

Posted By:      Posted Date: August 26, 2010    Points: 0   Category :ASP.Net

 Hi People, How are you all doing?

I have 2 pages one is SearchPage & It has DropDowns, textboxes to specify the search criteria. From the search result the user is redirected to another page when he clicks the hyperlink in the search result  where he fills in the information and again redirected to SearchPage. Now the SearchPage is posted back with no state i just want to retain the search criteria and display when user comes back. Please give me some suggestion how to get this done. I've used ViewState to save the values and check them in Page_Load but they are null.   



 Update: I've come up with this code. But the problem is The values are being retained but the Button_Click event is not being handled properly. When i Check the code even after this "DropDownList1.SelectedValue = Session["Name"].ToString();" DownList1.SelectedValue is EMPTY"" samw with DropDownList2 . please Suggest something


    protected void Page_Load(object sender, EventArgs e)
        if (IsControlsEmpty())
            if (SessionExist())
                DropDownList1.SelectedValue = Session["Name"].ToString()

View Complete Post

More Related Resource Links

Button to copy selected item in dropdown to textbox

Hi, I found this bit of code which I tried and it isn't working. I just want to place a button next to a dropdown, and when clicked, the selected item in the dropdown will put into another textbox. <head><title>Untitled</title></head><body><script type="text/javascript">function copy() {var sel = document.getElementById("names");var text = sel.options.value;var out = document.getElementById("output");out.value += text+"\n";}</script> <select id="names"><option>Product One</option><option>Product Two</option><option>Product Three</option><option>Product Four</option></select><input type="button" onclick="copy()" value="Copy"><textarea id="output"></textarea> </body></html>   I saved this as a file and opened it in IE to test and nothing went into the textarea. Also i tried it in Firefox and the textarea said undefined each time I click the button. Can someone help to get this working?

Values in multiselect dropdown not getting selected when Select All option is selected


Values in multiselect dropdown not getting selected when Select All option is selected for a SSRS dropdown.

There are multiple dropdowns on the page. We have one dropdown whose output is being used to populate the second dropdown using a stored procedure. When we check the Select All checkbox on the dropdown then ideally upon page refresh all the values should get selected in the dropdown, but in this case the page refreshes back to the blank dropdown, forcing the user to select the values again. The next dropdown too does not get populated. This makes it impossible to run the report for all the cases by using Select All.

We ran the report on differnet database environments. My current location is Mumbai,India, the report worked fine when we ran it on a Bangalore,india database. This issue occurs when we try running it on a Chicago database server.

I am using SSRS 2005, SQL2005.

If anybody has faced such an issue earlier, please help me out here.  Thank you. 


Passing values from textbox to labels on another page


I have a form with a combination of dropdownlists and textboxes that I want to be able to show a user as a summary in another page before submitting to a sql server. Page 1 will have a verify button which will then pass the dropdown and text box info to page 2 where end users will be able to either submit the page or cancel the action. What's the best way to pass the values from page 1 to page 2?

Thank you,


Lost TextBox values when page load


hi all

my question is i'm try to do auto complete function to calculate the total amount acording to some rate..i will put the code and you may understand what i try to explain

<table><tr><td>4. Enter Amount in <asp:DropDownList ID="amountddl" runat="server" AutoPostBack="True"                                                                                         OnSelectedIndexChanged="amountddl_SelectedIndexChanged">
                                                                                                                    <asp:ListItem Selected="True">SOURCE AMOUNT</asp:ListItem>
                                                                                                                    <asp:ListItem>DESTINATION AMOUNT</asp:ListItem>
 </td></tr>                                                                                                                                                                                                                           5. <tr><td>Destination Amount (<asp:Label ID="swiftcodelbl1" runat="server"&

how to filtering the autocomplete textbox values while selecting perticuler value in dropdown.


in my applicaion dropdown having country,state ,district  values  and one autocomplete textbox  , if i select country in the dropdown  only country names should be filtering in autocomplete textbox ..........can anybody tell me

thanks in advance


Dropdown list in ASP.NET - How to get value selected

am sure this must be very simple, but unforunately I can't figure it out.
I have the following code which populates the dropdown lists from the database. This works fine. Now, when the user selects a particular employee name from the list, I want to get the Employee Id of the selected employee. i.e. I need to get the "Eid" value. I can do this if the EId is loaded in the dropdown list, but in this case only the employee name is displayed. Please let me know howI can get the Eid value even though it is not loaded in the dropdown list.
I would really appreciate your help

Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List

This is an example of an editable gridview containing different ASP.NET controls. When user wants to edit values in gridview, she/he can use these controls to edit existing values in Gridview Edit Mode.

Using the Code

Selected to change the background color of the page



As this site, http://www.borfin.com.tr/genel/Default.aspx, How can I change the background color selected pages.

how to bind Dropdownlist based on textbox values



I have one drodownlist which show data based om textbox values...

Let us consider i have 

Select Name from table1 where Type IN(@typ)

here @typ is textbox values

here for example textbox will have some thing like this L1,L2,L3..

How to filter Name based and shown in drodownlist based on this L1,L2,L3(on textbox)..

Help me in this

update parentpage gridview with the values from child page?


hi   i am having a gridview on each row i am having a update and add button.

on click of either of the button i am opening a popup where the end user will enter data and on clck of ok button in the child page

based on the click ie

if i clicked update i need to update that particular row with the values from child page.

if i clicked on add i need to add a row below the row where i clicked add button .

can anyone help me with this?

Configure BDC column to have multiple values selected


How do I Configure BDC column to have multiple values selected and make multiple entities data available in the same column.  Currently it supports only single value for an item.  This requirement is crucial need some solution immediately.

How do you create a custom BDC data field that allows for multiple selected values?

I need help creating a custom data field using the BDC column as a base.  We need to allow for multiple selected values instead of just a single one.  I can't find anything on the net which shows how to do this.

Control Values When Returning to Page


Why do controls value not persist when returning to a page (e.g. via browser back button)?  If I set control values without utilizing a post back the controls will maintain their last value when I return to the page.  If I set a control value and then call a post back, the control value is reset to the default value when returning.

I have many pages with a gridview, and a textbox which is used to filter the gridview contents.  I set the filter textbox, filter the gridview (postback), go to another page, and when I return to the gridview page (via back button), my filter textbox is reset empty, and the gridview is the original (unfiltered) data.

What concept am I missing here?

Thanks in advance...

Javascript code to copy selected dropdown item to clipboard

Does anyone know how I can do this to get the text onto the clipboard?  <input id="Copy" type="button" value="Copy Url" runat="server" onclick="copy();" style="vertical-align: top;" visible="false"/><script type="text/javascript"> function copy() { var sel = document.getElementById("DropDownList1"); var text = sel.options[sel.selectedIndex].value; ??? } </script> </body>  

List does not exist The page you selected contains a list that does not exist. It may have been de

Hello All,   We are facing an error in our MOSS 2007 internet site.   We are unable to access the root site ,however all other site collections created using manged path under the root site are accessible.   The home page of the root site i.e http://servername/pages/default.aspx  navigates to custom error page , where as application pages like settings.aspx ,viewlsts.aspx throw below mentioned error   "List does not exist  The page you selected contains a list that does not exist.  It may have been deleted by another user" As a workaround , we tried restoring the rootsite from back up file (.dat) ,but we get the same error (mentioned above).   Content database is very much present and database server has good enough memory.   Any suggestions for this would be of great help.  

Passing values from web page to custom security trimmer in SharePoint 2010

Hi, In SharePoint 2007 we had a custom security trimmer that implemented ISecurityTrimmer interface. We also had a custom webpart used for search. Now, using HttpContext we passed values from the webpart to security trimmer with additional info needed to trim the results. It worked since trimmer was executed in the same w3wp process as webpart. Now in SharePoint 2010, the architecture for ISecurityTrimmer2 has changed, as it's executed in search process (other w3wp) - not the webpart w3wp so it has no access to the HttpContext. Question is: how to pass custom data, in form of the string, to a security trimmer when search is done from custom code in webart?

if 'other' from drop down is selected, the respective details textbox is now validated using a req

Hi, I'm developing a system with a number of drop down lists. One of the questions relates to the light conditions at the time of the incident (for example, it could be dark, poorly lit, dusk etc...)One of the options on the drop down list is 'other'. (i argue with my client that if they're using dropdown lists, don't use other, but they disagree)The next field is 'If other, please give details'. What i'm basically looking to acheive is to say that if you select 'other' from the dropdown list, the 'if other' field becomes required using a requiredfield validator. (and the reverse too, so if you choose a pre-poulated answer such as 'dusk', the 'if other' field is not required.)I have all my other validations working fine and my drop down list is populated from an SQLDatasource (not ASP.net Items)My dropdown list id= ddlLightMy 'other' field id= txtbxLightOtherMy required validator for the 'other' field id= requiredvalLightOthermy sqldatasource id= sqldatasourcelightI'm thinking something like this, but it's not quite working for me:If ddlLight.Text = ("other") Thentxtbxlightother...Any assistance would be great. I've done this before and i'nm frustrating myself as i can't seem to work it out!ThankMike
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend