.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

Select Item from Dropdownlist

Posted By:      Posted Date: September 22, 2010    Points: 0   Category :ASP.Net

I have a dropdown list created via MVCContrib FluentHTML - how do I perform a postback when the user selects any item in the dropdownlist? 

View Complete Post

More Related Resource Links

Dropdownlist postback always select first item


Hello, I am new at Asp.net. I hope some experts can help me.

I have 2 dropdownlist controls (ddl1 and ddl2). When I pick an item from ddl1, it will update ddl2. The problem is when I pick an item in ddl2, it always selects the first item in the list. Is it that the ddl2 autopostback causes the first ddl1 to reload and results the ddl2 to be refreshed also? Or I didn't set something correctly?

thanks in advance.


<asp:DropDownList ID="ddl1" runat="server" DataSourceID="sql

Populate a dataGridview based on select an item in dropdownlist!


Hello all!

In window form,  there are two comboBoxs named cbo1, cbo2 with populate the same items in the dropdownlist as following: For examples,

Class A

Class B

Class C

I like to populate the data into two dataGridViews named dgv1, dgv2 based on selecting an item in two dropdownlists. The rules is if I select an item in the cbo1 to populate data in dgv1, and cbo2 with hide (remove) an selected item from cbo2 to avoid that the user selects the same item for populate the same data in the dgv2. In a brief, the displayed data in two dgv1, dgv2 are different. Any helps in C# code, I really appreciate it. Thanks in advance.

On New Item form, select item on choice dropdown based on query result.


I posted this on Experts Exchange awhile back with no answer, so here's hoping someone here has an idea :)

So I've mostly figured this problem out, but I need some help in getting over the hump... note that I'm using JavaScript to do this (SPServices) on SharePoint 07'.

I'm on the New Items page of a list. Based on a user's selection in a "Teacher" dropdown, I'm doing the following:

1.) Get the value of the Teacher field and several other fields (School and Visit Date)
2.) Run a CAML query based on those fields to find the last list item entered for that Teacher

So here's where I'm stuck...

I have 10 choice fields, all with choices 0, 4, 7, and 10. Depending on what they were set to in the last entered item (which I queried), I want to set the selected item on each of those dropdowns to equal that. So "Score 1" was set to "4" on the la

DropDownList problems : The ViewData item that has the key 'userTYPE_id_user_type' is of type 'Sy

Hello,I've been searching for that problem for hours...I have two table :          -user          -userTypeI'm trying to create a user, wich as a column id_userType, so I'm trying to do a dropdownlist with the userType List I've that error code : The ViewData item that has the key 'userTYPE_id_user_type' is of type 'System.Int32' but must be of type 'IEnumerable<SelectListItem>'. // // GET: /User/Create public ActionResult Create() { //Send to the view, the userTypeList IEnumerable<SelectListItem> userTypeList = new SelectList(_userRepository.FindAllUserType().Distinct().ToList(), "id_user_type", "Description"); ViewData["userType_id_user_type"] = userTypeList; return View(); } here the post controller // // POST: /User/Create [HttpPost] public ActionResult Create(users user) { if (ModelState.IsValid) { try { _userRepository.addUser(user); _userRepository.save(); return RedirectToAction("Index"); } catch { return Vie

Can't select combobox item with mouse

I have a bizarre issue with my wpf 3.5 app that I just wrote. One of the computers we installed it on won't allow the user to select an item from the combobox with the mouse. The mouse can make the drop down appear like normal, but when the mouse hovers over the items they are not highlighted and clicking on one closes the drop down but doesn't select the item. This is the default combobox with no style and only the margin, itemssource and selecteditem properties set. I tried other programs that have comboboxes (IE7, Excel, a VB6 app) and all of them work just fine. We have this program installed on numerous computers throughout our company and everyone else's is working correctly. I tried uninstalling the program and the .NET framework then reinstalling. I don't know what else to try.

CascadingDropdown Extender select item on pageload

I have a form that two cascadingdropdown extenders, when the page loads  the form is populated and cascadingdropdowns do work however the values should be set as the page loads.  I have tried setting the selectedvalue of the CDD but that doesn't take.   How do I set the values of the CDD with data from a db?

Problem Add Category Item by select department

Add Category Item by select department Firstly database has two tables Department and Category Department Table Id -------int  (PK) dep_name--------nvarchar(50) dep_description---------nvarchar(100) -------------------------------------------------------- Category Table Id------int cat_name------- nvarchar(50) cat_description----------- nvarchar(100) IsActive--------bit DepartmentId-----int   (FK) ---------------------------------------------------------- I have form contain DetailsView control under name CategoryDetailsView. My problem: this mechanism not duo correctly I don't know why,  only show to me when I run page" Procedure or function InsertCategory has too many arguments specified. " My idea when a user need to create category must on him write category details ( category name, Description, IsActive) and select this category where to insert by select department name from drop downlist This control connecting with table under name Category, insert process by stored procedure under name sp_InsertCategoryALTER Procedure [dbo].[InsertCategory] (@cat_name nvarchar(50) ,@cat_description nvarchar(100),@IsActive bit , @Result int output)AsBegin Insert Into Category (cat_name , cat_description, IsActive ) Values (@cat_name , @cat_description, @IsActive ) Select @Result = @@IdentityEnd <asp:DetailsView ID="CategoryDetailsView

Dynamically add item to DropDownList??

I have an Edit page in my application that contains a DropDownList. This DDL is bound to an EntityDataSource that only shows the active "ProjectManagers". In the case where the user is editing a record that is assigned to an "inactive" ProjectManger, an "ArgumentOutOfRange" Exception is (rightfully) thrown by the DDL (because that Item wan't bound to the list, since it only binds "Active" ProjectManagers). So, I need to add this item to the DropDownList dynamically or at least add an "Inactive" item and then "select" that item in the code behind. (Although, adding an "Inactive" item would force the user to actually change the ProjectManager and that wouldn't be a good idea.) I have tried handling the OnDataBinding method with the following code:   protected void PreventErrorOnBinding(object sender, EventArgs e)    {        DropDownList theDropDownList = (DropDownList)sender;        theDropDownList.DataBinding -= new EventHandler(PreventErrorOnbinding);        theDropDownList.AppendDataBoundItems = true;        ListItem li = new ListItem(""<<Inactive>>", "0");     

How to get item selected in dropdownlist

I'm searching and trying now for the last couple of hours, so I thought the community might help.I'm filtering the rows in a gridview using a ddlDate. Now, I want to request this selected item.But: When I load the page without clicking in the DropDownList, the ddlDate.SelectedValue is empty, and the ddlDate.SelectedItem.Text.ToString() gives a NullReferenceException.Is there any way to fix this without using a listbox?

Databound DropDownList Item Value Property Localization

I am using a databound DropDownList in which the item's Text field is set to a text representation of an identifier value of type int.  I am filling the Value field of the ListItem with the int value.  All of this is being done through the setup of the DataTextField and DataValueField settings of the DropDownList control. However, since both the item Value and Text fields are strings, obviously a conversion must be performed at the time of binding to convert the non-string value to a string value.  I am making the assumption that the ToString() method for the value is invoked in order to convert the int value into a string so that it can be stored in the Value property of the ListItem. Once selections are made, I read the Value property of the SelectedItem to perform an action.  It occurred to me that converting back to the original data type might present a problem if the wrong culture information is used to perform the conversion. My question is, in the case of non-string values being automatically converted for a databound DropDownList, what culture is used to perform that conversion?  My initial guess would be the CurrentCulture, simply because no object is required to supply a ToString() overload which allows the specification of an IFormatProvider object.  However, if the System.Convert object is used to perform the conversion

dropdownlist selected item problum

In gridview we have edit button whenever user click edit button i want to show particular data of dropdownlist as a selected data that is selected by user as a selected text of dropdownlistis there any solution ???

select n-th item

I would like to select the n-th item from a list. One way I know how to do it is like this. Please follow this example. Create a table and insert a bunch of integers in random order. create table A (col int) insert into A values (294) insert into A values (150) insert into A values (200) insert into A values (12) insert into A values (1000) insert into A values (56) insert into A values (750) insert into A values (62) insert into A values (560) If I want to select the N-th largerst number from table A, I can do this. (replace <N> with whatever number you want) select max(x.col) from ( (select top <N> col from A order by col) ) x So, if N = 5, then you should get 200 from the above example.   I'm looking for another way to do this using the rank() function. I know you can use rank() like this. select rank() over (order by col) num_rank, col from A But, how can I use num_rank column to get the N-th item. I tried something like this, but doesn't work. select rank() over (order by col) num_rank, col from A where rank() over (order by col) = 5  

Dropdownlist not firing SelectedIndexChanged on first item with autopostback true

Hi: Has anyone ever found a work around for the well documented and well known bug, the dropdownlist bug? Specifically where the SelectedIndexChange event does not fire on the first listitem, althought both autopostback and enableviewstate are true? In other words, if the first three items in the dropdownlist are red, blue, green, if you select green, the SelectedIndexChanged will fire, but if you then select red, the first item in the ddl, the event will not fire. All listitems will fire the SelectedIndexChanged event, except for the very first listitem. The HACK has always been to include a dummy item as the first list time like"Select a Color" to get around the first item bug. I have got a situation where I cannot use that hack. Ideas?  TIA, Bill  

Dropdown select message in item template gridview dropdwon list ???

Hi ....I have used gridview item template , which has two dropdown list .The first dropdown list is binded from database to the dropdown list I have using the below code , to show the select message in dropdown list before selecting any item from dropdown list.In first row its show me --Select-- message and my vaues.. if i select some value form dropdownlist and click add new button it will create a new row dynamic then in previous row again it come back --Select-- message... on going to second row....I need to remain first row user selected value on going to next row.The New row will show --select-- message..Please go to my code and let me know what to do<asp:DropDownList id="DropDonList2" tabIndex=11 runat="server"          OnSelectedIndexChanged="DropDonList2_SelectedIndexChanged" AutoPostBack="True"          DataTextField="SizeRange" DataValueField="SizeRange"          OnDataBound="DropDonList2_DataBound" __designer:wfdid="w10"          AppendDataBoundItems="True">  <asp:ListItem Value="-1">Select</asp:ListItem> </asp:DropDownList><asp:DropDownList id="DropDonList2" tabIndex=11 runat="server" 

disable a single intem in dropdownlist or stop the ddl change event for a single item


hello guys,

I am trying something apart of my boundries, is there any way to disable a single intem in dropdownlist or stop the ddl change event for a single item.

any feadback would be appriciable.

Thanks and Regards

Inderjeet Singh Khalsa

Automatically select item with keyboard navigation in a combobox


Hi there,

in a WinForms ComboBox the selected item automatically changes, when I navigate through the combobox items with keyboard.

However, in the WPF ComboBox (IsEditable = false), the item in the list is highlighted but not automatically selected. Is there a way to change this behaviour?




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