getting dropdown list value from usercontrol to change session variable


I have a problem,
I have a user control that has 2 drop down lists, what I need to do is use the value of the selected item in the dropdown list to use in the selection of data in a datagrid on the main page.
Basically I just need to take the values, and be able to plug them in (during a page load event) and use them in the query.
Right now the usercontrol gets fired AFTER all of the other things are loaded. I thought that by setting a session to the value of the drpdown list would work, but its not triggering anything because 1, its a post back event, and two the usercontrol is getting loaded after the page_load event, so to re-bind, it would have to be refreshed by hitting f5
What I want to happen is the user will change selection from the dropdown box, and then have the datagrid re-load the data based on the value of the selected item in the dopdown box.
The setup has to all be done on the parent page since there are several different pages that are based on this data in the dropdown lists.

Ive looked high and low, but have found nothing usable (or even understandable) so any help would be appreciated.
Thanks
Frank
0
daremo
12/4/2003 12:56:42 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

3 Replies
1359 Views

Similar Articles

[PageSpeed] 32

You don't have to look high or low for this one. To be absolutely certain the grid reloads immediately AFTER a SelectedIndexChanged for one of the dropdowns, all you do is declare a public event for the user control. Once a dropdown is modified you trigger the event and the grid, who is of course subscribing to this particular event will reload. Here are some skeletons that hopefully will guide you:

Inside the user control:

public event EventHandler ListChanged;
..
..
..
private void yourList_SelectedIndexChanged(object sender, System.EventArgs e)
{
//Do whatever you did before here!
//Trigger the change event
OnListChanged();
}
private void OnListChanged()
{
//Only trigger if there are subscribers!
if (ListChanged != null)
{
ListChanged(this, null);
}
}

In the main page:

MyControl theControl;
..
..
..
private void theControl_ListChanged(object sender, System.EventArgs e)
{
//Reload the grid here!
}

Inside the InitializeComponent method of your main page:

this.theControl.ListChanged += new System.EventHandler(this.theControl_ListChanged);

I hope I didn't overlook some parts needed. But the idea has worked for me every time and it should get you going.
/Skalman
0
skalman
12/4/2003 8:59:19 AM

That sounds good, Ill try it out this afternoon after I get some other things finished up.
I really appreciate your input on this, I could find hide nor hair of an answer in any forum or MSDN and Im still too new to know enuff to figure the harder stuff out.
Thanks again
Frank
0
daremo
12/4/2003 6:54:09 PM

I'm looking at this and understand everything except where the MyControl theControl; comes from (or where it goes).
Can you give me an idea where I put that?
Thanks again
Frank
0
daremo
12/4/2003 7:49:25 PM
Reply:

Similar Artilces:

How to get value from first dropdown list to second dropdown list
Hi Does soneone know hot to get value from first dropdown list to second dropdown list or remove it from seond dropdown list? I have a web form page. On the page, there are two dropdown lists, one Add button, and one Remove button . First dropdown list has four list items. Second one does not have list item yet. When select a item from first dropdown list, then click "add" button. I want it to apear in the second dropdown list without reload the page. Or select item from second dropdown list, and click "Remove" button. it will remove from second list. Please help. &nb...

How to use values from two dropdown lists to get the value for a third dropdown?
I have three dropdown lists.  One for Office, one for Department, and a list of employees.   There is no relationship in the database between office and department.  The relationships are to the employees.  What I need to do is take the selected values from Office and Department, and run a query to get the list of employees who match both parameters (Office & Department).  Here's my code for the three dropdown lists.  How do I "connect" Office & Department to populate employees?  code from my vb.net page    for the ...

Drop down list in Form view returns error when value in bound field (data binding
I get the following error when I click edit to edit the details in the web form:'ddlUserRestrictionType' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: value  I would like it to accept any value which currently exists in the database. Is this easily achievable? With what you've posted, all I can tell is that you are trying to set the SelectedValue of a ddl to a value that does not exist in the list.  It would be helpful if you can post some code and the expected values of this control.~ Timwww.bucketo...

getting the value of a dropdown list that's in a usercontrol
Hello, I have created a user control that populates a dropdown list. I can get the control to work perfectly on an .aspx page and the code behind file, but I cannot get the value that is selected. <form id="Form1" method="post" runat="server"> <uc1:sortOrder id="SortOrder1" runat="server"></uc1:sortOrder> <asp:Button id="Button1" runat="server" Text="Button"></asp:Button> </form> The name if the dropdownlist in the user control is ddlSortOrder. M...

Sorting microsoft report on web form from dropdown list values
Hi, I have a Microsoft report viewer tied into an object data source. The object data source is pointing to a data table .xsd file. I have setup my filtering using parameters in SQL and tying those parameters to controls on my web form to filter the report. That is working fine, however I also want to be able to use a dropdown list to select the fields to sort the report by, as well as what order ascending or descending.  I know you cannot use parameters in the Sort By column in SQL so I have been trying to use the SORT BY CASE statement then pointing those parameters to the dropdowns...

Changed values not getting passed to UPDATE SQL function on web form
So I have a form that has been giving me fits... It's a form to edit a database entry; on Page_Load, data from the entry loads on the page in various fields (textboxes, drop-down lists, radio button lists, etc). The idea is that the user should be able to upate that data as needed, then hit a "save" button, and an UPDATE query saves the new data to the database. What's happening instead, however, is that the old unchanged data is being passed to the UPDATE query, rather than the new data. Except in one wierd case, when a record is created with only the bare minimum of inf...

getting values from a web form to windows form
Hot Requirement ..... Is there any possible of getting values from a web form to windows form ????? Yes One way i to use the WebRequest and WebResponse classes of the System.Net namespace. For example:  WebRequest request = WebRequest.Create("URL of the web page); WebResponse response = request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string content = reader.ReadLine(); ....    Reza Nassabehwww.professionalcsharp.comDon't forget to click "Mark as Answer" on the post that helped you. That way fut...

How to get session variable value into a static variable
Hi, On page preinit i am adding few session variables. Now i want to retrive these session variable values into my static variables. protected void Page_PreInit(object sender, EventArgs e) {Session.Add("T", "Default"); Session.Add("T1", "Red"); Session.Add("T2", "Blue");   }   i have few static variables which shud contain these vaules.  public string TT; public string TT1; public string TextForeColor =sess = "#FFFFFF";   i want to get T value into TT ... T1 into TT1..and so on &n...

how i can get the one form variable values in other forms?????
iam going to pass values of one form to another formlike asfollows.. f1=CType(Context.Handler ,f1);here f1 is form object this will be used in some other form.iam try ing to use to global variables of first form in to second form.while compilation it show s an error like as follws:"The name 'CType' does not exist in the class or namespace 'PassingValuesForms.Form2'can you giv aslo pls..thanks in advance..ramsCheersRam MCP CType is for the VB.NET language exclusively. By adding a semicolon to your code, I'm guessing you are using C#.CType provides VB users with typecasting. In C#, the lang...

Password text value gets deleted when value selected from Dropdown list
Hi, I need help in my dropdown control, this is what my problem is I am using DropDown List in my aplication in a form and i want to show some default selected value in the first drop down D1 and depending on values selected in D1 the values gets displayed in the child drop down D2. My issue is i have a password texbox before getting valued from D1 and D2......when i select value from D1 the password enetered in hte password textbox in password mode gets deleted. so every time he user types the password and then select something in the dropdown, he has to ...

Populating and Implementing 4 Dropdown lists on web form through web service
Hi all, I have a Project due after one week. It is a web service project. I have a Web Form which communicates to the web service and this web service communicates to the database. I have all my SQL statements in the Data Acess Layer to create more secure web service application. The Web service class is also in the Data Access Layer. I need to populates the 4 Dropdown list boxes on the web form from one table. I have Customer table which contains information About CustomerName, CustomerType, Address, City. These 4 colum values should populate the 4 Dropdown lists. And then I need to implem...

changing the selected value for the dropdown list to match a query string value
My url looks something like this "http://www.imaslog.com/real_world/send_messages.aspx?recipient=cheatcountry and on that page I want the dropdownlist selected value to show up as cheatcountry automatically if that is what the query string is. How do i do this? Hi, QueryStrings can't be read via javascript. If your select box (combo box) is a html control and not DropDownList server control. You do a normal static variable to set the selected property in the combo box to this variable. You then use the server side to read the query string and pass the selected value to this j...

Load Text box of one web form with selected list item of list box of another web form
one help please Problem is i have two web forms  1.  ForiegnkeyTest.aspx  2. foroginkeytable.aspx   step 1 1 ForiegnkeyTest.aspx one web form <head runat="server"><script language="javascript" type="text/javascript">   function popWin()   {         var confirmWin = null;      confirmWin = window.open('foroginkeytable.aspx','anycontent',   'width=455,height=435,status');   }  </script> &...

My session variables get cleared session is alive when code is changed in the class files.
Dear Friends,I am working on visual studio 2005. I have written some forms which are using some classes. I keep on making changes in form code. Session variables retain their values. But when a minor change is done in the class file, session variables are cleared of where as the session is alive.Please help me in troubleshooting this.Thanks in advance.Best Regards,Fazal.  You are saying right. Store static values during development like    page_load         Session("variable")=value  check some articleshttp://www.co...

Web resources about - getting dropdown list value from usercontrol to change session variable - asp.net.web-forms

'url' Top Users - Stack Overflow
current community chat blog Stack Overflow Meta Stack Overflow Stack Overflow Careers your communities Sign up or log in to customize your list. ...

List of content management frameworks - Wikipedia, the free encyclopedia
.NET Framework , works with SQL Server, VistaDB , with XSLT or .NET UserControls Text is available under the Creative Commons Attribution-ShareAlike ...

OPAC Discovery
Switch Language To switch to a different language, select from the following list: English French Spanish Italian British Bulgarian Galician ...

The royal baby - Australian Women's Weekly
MAKE AWW MY HOMEPAGE SUBSCRIBE AND SAVE TODAY FOOD RECIPES ROYALS CELEBS Home Food Recipe search Recipe collections Meal maker Expert Q & A Cookbooks ...

Envoyer par courriel à un ami - Best Buy Canada
Envoyer par courriel à un ami à Best Buy Canada

Bytes - IT + Developer Community - Connect with IT Pros
Bytes.com is a community for Developers and IT Professionals. Join 414,150 members and discuss topics such as software development, networking, ...

Canonical Splines in WPF and Silverlight
January 22, 2009 New York, N.Y. Windows Forms has two methods named DrawCurve and DrawClosedCurve that draw canonical (aka cardinal) splines. ...

Silverlight Toolkit - Issues
Silverlight Toolkit and Silverlight for Windows Phone Toolkit are a set of Microsoft components for developers.

Delicious
Keep, share, and discover the best of the Web using Delicious, the world's leading social bookmarking service.

DotNetNuke Modules – Anatomy of the View
-*+Now that we’ve laid the foundation of DotNetNuke modules, it is time to start looking at the specific modules. While it would be practically ...

Resources last updated: 12/31/2015 6:19:34 AM