Tracking Forums, Newsgroups, Maling Lists
Home Submit Tracker Forums
  Advanced Search


Populating A Dropdown List Based On Value Selected In Previous List (mvc3)

I'm trying to progam a strongly typed "Create" view using MVC 3 and razor. I want the user to be able to select a customer from a dropdown list (I populated this from my database using ViewBag in the controller). When the user has selected a customer I want a separate dropdown list to generate a list of dogs belonging to that customer related by the customerID in the database. The create button on the form will then take both of these values along with the the other fields and save it to the database.

View 1 Replies (Posted: Mar 18 at 18:55)

Sponsored Links:

Related Forum Messages For ASP.NET category:
Populating Dropdown List With Previous Dates?
I have to populate1st drop down list with today's date and 100 datesprior to today. I am trying to use adddays method but in reverse order. With adddays I have today's date and next 100 dates. This code doesn't work:

Dim i
For i = 1
To 100
Next i

The 2nd dropdown should read date selected from 1st dropdown and then populate 2nd dropdown list with 7 days preceeding the selected date.

Posted: Mar 02, 2009 03:01 PM

View 5 Replies!   View Related
AJAX :: Display Cascading Dropdown List Based On Checkbox List Selected Value
How can i generate dropdown lists based on what has been selected in the checckbox list.Below is an example of what i need. if the user selects the options day, lotID and waferID, then 3 cascading dropdown lists should be displayed. And then a gridview displays data based on what has been chosen in the dropdown lists.


Posted: Nov 10, 2010 05:26 AM

View 3 Replies!   View Related
C# - How To Disable Dropdown List Value In The Current Form That Was Selected In The Previous Page
I am having 2 web formsand will have a drop down list on those web forms. If i select a value from drop down and click on ok i will get tranfer to next page. In that page i will have a drop down with the same values in the previous form . What i need is i would like to disable the selected value in the previos form and would like to display the remaining normal

Posted: Aug 27 10 at 10:42

View 2 Replies!   View Related
Web Forms :: Populating Text Boxes Based On Dropdown List Selection From Stored Procedure?
I have a drop down list being populated from a stored procedure. The drop down list contains job titles and there are text boxes that I need to populate with the corresponding pay structures based on the selection from the drop down list. Those pay structure values are also located in my database. Something tells me that I will need a second stored procedure to accomplish this.

Posted: Aug 26, 2009 09:50 PM

View 2 Replies!   View Related
Web Forms :: How To Disable Dropdown List Value In The Current Form That Was Selected In The Previous Page
I am having 2 web formsand will have a drop down list on those web forms. If i select a value from drop down and click on ok i will get tranfer to next page. In that page i will have a drop down with the same values in the previous form . What i need is i would like to disable the selected value in the previos form and would like to display the remaining normal.

Posted: Aug 27, 2010 10:53 AM

View 3 Replies!   View Related
AJAX :: Open Modelpopup Window Based On Value Selected In Dropdown List?
Is there a way to open modelpopup window based on value seleted in dropdown list? I want to open a window when Urgent is selected in the dropdown list=!!!!

here is the code for ModalPopupExtender:

<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server"


Posted: May 27, 2010 09:07 PM

View 4 Replies!   View Related
Forms Data Controls :: Display A Popup Comment Box Based A Selected Value From A Dropdown List Control?
How can I display a popup combo box or make visible a comment box if i select the value other form a visual studio drop down list. The drop down list control is within FormView1.I am using visual studio 2005.

Posted: Nov 23, 2009 10:57 PM

View 4 Replies!   View Related
Web Forms :: Clicking The Label Of A Dropdown List - Resets The Selected Value To The First Item In The List?
Clicking the label of a drop down list, re-sets the selected value to the first item in the list. This has a history of causing data entry problems when users accidently click on the label.

In the below example ddlContactType has a selected value as 'PRIMARY' and whenever i click on the lblContactType Text, the dropdown box Selected value is changing to "Select One" Text.

How to prevent this one. It should be on PRIMARY Only.

<tr> <td ><asp:Label ID="lblContactType" Font-Bold="true" Text="Contract Type: *" ForeColor= "red" runat="server" AssociatedControlID="ddlContactType"></asp:Label> </td> <td > <asp:DropDownList runat="server" ID="ddlContactType" DataSourceID="SqlDataSource2" AppendDataBoundItems="true"
DataTextField="TYPE" DataValueField="ID" SelectedValue='<%# Bind("CONTACT_TYPE_ID") %>'>
<asp:ListItem Text="Select One" Value="0" Selected="True"></asp:ListItem>.......

Posted: Feb 17, 2010 02:26 PM

View 4 Replies!   View Related
Web Forms :: Dropdown List Not Populating
Dropdown list not populating






Posted: Sep 17, 2009 07:44 PM

View 6 Replies!   View Related
Populating A DropDown List With Multiple Items?
I am running into some additional difficulties with dropdown lists, and I'm hoping you can correct my thinking.

I have a table populated with items; ITEM_ID, ITEM_NAME, ITEM_COST.

Here is my code:


With this code I get this error: DataBinding: 'ITEM' does not contain a property with the name '2'.

If I remove the assignment of DataSource to c1, the dropdown generates this error: 'DropDownList3' has a SelectedValue which is invalid because it does not exist in the list of items.

Parameter name: value

How should I code this so that the user is presented with a list of ITEM_NAMES, and that the ITEM_ID is stored in the value field so I can use it when the selection event is fired? I know I could databind the source directly to the dropdown list, but I am trying to understand the behind the scenes working of a dropdown list object.

Posted: Apr 30, 2010 10:05 PM

View 5 Replies!   View Related
C# - Populating Dropdown List With Enum Using Reflection?
I am populating a page with controls reading properties of a class using reflection. If the property type is 'String' I will add a text-box. If the property type is enum I am adding a dropdownlist. Now I have to populate the dropdown options with enums. How can this be done?

Both the enum definition class(Assignment) and the class(classOne) using which I am populating the page with controls are in the same Namespace(MySolution.Data). While looping through classOne properties when the property name is 'SkillLevel' I will have to go to assignment class get the members of enum SkillLevelEnum and populate the dropdown.

Same needs to be done for other dropdowns also.

My Code:

namespace MySolution.Data
public class classOne : MyAdapter
private string _Model;


Posted: Mar 29 at 5:06

View 4 Replies!   View Related
Populating DropDown List / How To Populate With Values From A Table
I have a DropDownList called "ddlCountry" that I need to populate with values from a table. Normally I would just push the recordset's "countryName" field into an array and useddlCountry.DataBind to populate it with the array.

resulting in something like this:


Posted: Jun 25, 2009 06:32 PM

View 3 Replies!   View Related
Web Forms :: Populating Dropdown List To Show Many Integers
I want to populate a Dropdown list from divisons of a figure in my projects database

for example database figure 50

I want the dropdown list to show 5,10,15,20,25,30,35,40,45,50

The database figure wont always be the same.

how would i go about doing this ? esp the populating of the dropdown list itself based on the way i want to show it.

Posted: Mar 19, 2010 12:17 PM

View 3 Replies!   View Related
Update Panel - Populating Dropdown List From Database
I have a ASP.NET AJAX Autocomplete Textbox and Two other dropdownlist in a Update Panel. On selection of an item in Autocomplete Textbox, I want to populate Dropdown list from Database.

Posted: Mar 25 at 16:10

View 1 Replies!   View Related
Web Forms :: Dropdown List With Previous Month?
I have a dropdown list for last months reports. the following is the code:


But this month as of Jan 2011, the dropdown list for the month shows December, but the year is current, i.e. 2011;

guide me how can i accomplish this.

Posted: Jan 05, 2011 05:07 AM

View 4 Replies!   View Related
Web Forms :: Populating A Text Box With Data From DropDown List On Page Load?
I have a dropdown control that has a list of names in it called PlayerNameDropDownList_Insert and a textBox called PlayerName.

When I select a name from the dropdown it populates the textbox correctly.However, when the page opens the first name is selected in the dropdown but nothing in the textbox.How can I get the textbox to populate with the value of the dropdown at pageload?


Posted: Mar 09, 2011 05:42 PM

View 4 Replies!   View Related
Web Forms :: DropDown List Not Populating When Text Changes In The Textbox Its Query Fires Off
I have a query that ties into two other controls (2 textboxes) -- this query is used to populate one of my drop down lists to show the amount of vendors a certain company has -- the query allows me to do a search (based off of the company's name (which i get from textbox1) and then search criteria which I get from searchbox 2. Its not reading from searchbox2 when i put my search criteria in and i was wondering how i could get it to populate correctly.

Posted: Sep 14, 2009 04:59 AM

View 3 Replies!   View Related
Web Forms :: Dropdown Selection Based On Other Dropdown List For State, City, Zipcode?
I got a qq.I have 3 Dropdownlists.State,city, zipcode. I will be loading state from stored proc. For City I will be loading based on State from stored proc. For zipcode I will be loading on State, city from stored proc. When I am selecting state I am getting city list in city dropdown.But I am loosing the values from state dropdown list.i want to show selected state value in dropdownlist.Why its become empty.I will be loading zipcodes based on State & City. Why I am loosing the state values.??Can you suggest me... I copied my code below.


Posted: Dec 03, 2009 03:14 PM

View 3 Replies!   View Related
JQGrid Inline Editing - Filter Subcategory Dropdown List Based On Another Category Dropdown
I have a category and a subcategory column in a Jqgrid. I have enabled inline editing, both category and subcategory are dropdownlists columns (edittype:'select'). I need to filter the subcategory list based on the selected category. I wonder how can I acheive this functionlity? I tried the below event but its not working for me

afterEditCell: function(rowid, celname, value, iRow, iCol) {
//to do here

the above event doesn't get fired. my all column are editable

Posted: Jul 9 10 at 14:02

View 1 Replies!   View Related
Forms Data Controls :: 2 Dropdown List / "Displaying A Dropdown List Of Categories With A --None -- Option?
I am stuck at this point "Displaying a dropdown list of Categories with a --None -- Option. I want the gridview control to display 2 dropdown list one in read-only mode and the other in edit mode. When a record is in read-only mode, the dropdownlist's enabled property will be set to false."When it's on a read-only mode, it doesn't display the selected Category. it shows but the "No Category". When i click on edit to edit or change category, it doesn't display the selected category.

The example is given below( I am reading the book Sams Teach yourself ASP.NET 2.0 by Scott Mitchell. page 628)

<asp:Label ID="UserIdValue" runat="server" Visible="False"></asp:Label>
<asp:SqlDataSource ID="picturesDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [Pictures] WHERE ([UserId] = @UserId) ORDER BY [UploadedOn] DESC"
DeleteCommand="DELETE FROM [Pictures] WHERE [PictureID] = @PictureID"
InsertCommand="INSERT INTO [Pictures] ([UserId], [CategoryID], [Title], [Description], [UploadedOn]) VALUES (@UserId, @CategoryID, @Title, @Description, @UploadedOn)"
UpdateCommand="UPDATE [Pictures] SET [UserId] = @UserId, [CategoryID] = @CategoryID, [Title] = @Title, [Description] = @Description, [UploadedOn] = @UploadedOn WHERE [PictureID] = @PictureID">
<asp:Parameter Name="PictureID" Type="Int32" />
<asp:Parameter Name="UserId" />
<asp:Parameter Name="CategoryID" Type="Int32" />
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="UploadedOn" Type="DateTime" />
<asp:ControlParameter ControlID="UserIdValue" Name="UserId" PropertyName="Text"/>
<asp:Parameter Name="UserId"/>
<asp:Parameter Name="CategoryID" Type="Int32" />
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Description" Type="String" />
<asp:Parameter Name="UploadedOn" Type="DateTime" />
<asp:Parameter Name="PictureID" Type="Int32" />
<br />
<asp:SqlDataSource ID="categoriesDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [CategoryID], [Name] FROM [Categories] WHERE ([UserId] = @UserId)">
<asp:ControlParameter ControlID="UserIdValue" Name="UserId" PropertyName="Text" />
<br />
<asp:SqlDataSource ID="maxPictureIDDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT MAX(PictureID)
FROM Pictures
WHERE UserId = @UserId">
<asp:ControlParameter ControlID="UserIdValue" Name="UserId"
PropertyName="Text" />
<br />
<asp:Label ID="cannotUploadImageMessage" runat="server"
Text="The photo could not be added to your album either because you did not specify a file to upload or the file specified was not a JPEG image with the file extension .JPG"></asp:Label>
<br />
<asp:DetailsView ID="dvPictureInsert" runat="server"
DataSourceID="PicturesDataSource" Height="50px" Width="125px"
AutoGenerateRows="False" CellPadding="4" DataKeyNames="PictureID"
DefaultMode="Insert" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" />
<CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
<EditRowStyle BackColor="#2461BF" />
<FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
<asp:TemplateField HeaderText="Picture">
<asp:FileUpload ID="imageUpload" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="imageUpload" Display="Dynamic"
ErrorMessage="There was no file selected" ValidationGroup="PictureAdd"></asp:RequiredFieldValidator>
<asp:TemplateField HeaderText="Category" SortExpression="CategoryID">
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("CategoryID") %>'></asp:TextBox>
<asp:DropDownList ID="pictureCategory" DataSourceID="categoriesDataSource"
runat="server" DataTextField="Name" DataValueField="CategoryID"
SelectedValue='<%# Bind("CategoryID") %>'
Visible='<%# Bind("CategoryID") %>' AppendDataBoundItems="True">
<asp:ListItem Selected="True" Value="">-- Select Category --</asp:ListItem>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("CategoryID") %>'></asp:Label>
<asp:TemplateField HeaderText="Title" SortExpression="Title">
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" Display="Dynamic"
ErrorMessage="you must provide a name for the title"
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Title") %>'></asp:Label>
<asp:TemplateField HeaderText="Description" SortExpression="Description">
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Description") %>'

Posted: Oct 10, 2010 07:47 PM

View 2 Replies!   View Related
Trying To Set Selected Value On A Dropdown List
I'm trying to set the selected value of a dropdown list, but it just doesn't seem to work. I've gone so far as to display a label next to the dropdown list to make sure my query is working properly. What am I missing? My code is below... page where I set the sqldatasource, dropdown list, and my temporary "label"


Posted: Nov 17, 2008 02:15 PM

View 8 Replies!   View Related
Getting Selected Value From A Dropdown List
im using a dropdown list in a gridview. the list is databound to a table. im trying to retreive the selected value in the click event of a button, but i always get the first value. i have visited many forums but couldnt get anything.

Posted: Jan 22, 2009 07:04 PM

View 9 Replies!   View Related
Dropdown List Selected Value?
In my application iam having two dropdownlist .i bind the the database to dropdownlist using c# with but i store the datavaluefeild(id).similar way i fallow for another ddl also. My Aim is while selected index change event of first ddl i have show the corresponding text of second ddl in front end....both the textbox i store the selected value in database

Posted: Nov 23, 2010 05:12 PM

View 1 Replies!   View Related
How To Get The Value Selected From Dropdown Instead Of 1st Value In List
I have a simple page. On it is a dynamic dropdown list. And when the user clicks the continue button, I want to grab the value they selected in the drop down, however my code below doesn't grab the value they select, it always grabs the first value from the drop down list. what am I doing wrong? I want to set the value of a hidden field (hdnMatterID) equal to the value selected in the ddInProgress Matters drop down list.

Protected Sub btnContinueInProgressMatters_Click(ByVal
sender As
ByVal e
As System.EventArgs)
Handles btnContinueInProgressMatters.Click
hdnMatterID.Value = ddInProgressMatters.SelectedValue

Posted: May 21, 2009 06:40 PM

View 15 Replies!   View Related
MVC :: How To Set The Default Selected Value For A Dropdown List
how i can set the default selected value for a dropdown list. My actual code is:


the GetAvatars() function return a List<MyObject> that contains the avatars informations such as filename and file url. I don't know if i this is correct, anyway i want to display a selectbox that shows the list of the avatars in a folder with a predefinited avatar selected and i would like to show an image near the selectbox with the current selected avatar. How can i do it? I don't find any way to set the default value

Posted: Aug 31, 2010 02:46 PM

View 4 Replies!   View Related
MVC :: DropDown List Selected Property Not Set?
I have a main "index" view that has a drop down and a submit button. When a selection is made (CampaignId) and a submit button is pressed a list of items is displayed and filtered based on the selection from the drop down list.

I've added a partial view (on the right rail) of my site that lists a bunch of campaigns. when a link is pressed in that partial view a (CampaignId) is passed to my page and the same thing happends as if you would make a selection from the drop down. The issue is that the dropdown "Campaign Name" should be selected based on the selection from the partial view.


Posted: Mar 09, 2010 10:17 AM

View 1 Replies!   View Related
How To Specify The Selected Option To A Dropdown List MVC
I have a list of options (IEnumerable< SelectListItem >) in my model that I want to use in multiple dropdowns in my view. But each of these dropdowns could have a different selected option.

Is there an easy way to simply specfiy which should be selected if using the Html.DropDownList helper?

At this point, the only way I can see is to generate the html myself and loop through the list of options like so:


Posted: Apr 14 10 at 23:06

View 3 Replies!   View Related
MVC :: Dropdown List Selected Item Asp.2
After validation dropdown list do not select previous value.

<%: Html.DropDownList("Country",(SelectList)ViewData["Country"],"") %>

However in Quick View there is correct selected value. :(

Posted: Jul 24, 2010 11:17 AM

View 2 Replies!   View Related
Selected Value From A Dropdown List Not Displayed?
i have a dropdown list which has three options. The "select" option is displayed by default.

None of the other options work when clicked.

this is the code that i use in vb:

If DropDownListSelect.Text =
LabelError.Text = "Select an option to continue."
ElseIf DropDownListSelect.SelectedItem.Value.Trim =
"Associate Inventory to PAC"
GridViewConfigure.DataSource = tblAdinvtopac.GetData()
'ElseIf DropDownListSelect.SelectedItem.Value.Trim = "Bench to Bench" Then
'ElseIf DropDownListSelect.SelectedItem.Selected = "Associate Bench to PAC" Then
' MsgBox("1")

The page displays the select option by default. even when some other option is selected in the DropDown list , there is no change in the page.

The grid that i am trying to display in one of the selected options of the dropdown list is displayed otherwise.

i cant understand why the grid never shows up when i select the corresponding option in the dropdown list.

Posted: May 08, 2009 01:51 PM

View 4 Replies!   View Related
JQuery :: How To Get Selected Value Of Dropdown List
i am assgining an values to drop down list using javascript onchange event of another drop down.

every thing is working fine,but when i try to get the value of selected dropdrown it is giving me nothing

as my dropdown declare as fallows



Posted: Nov 03, 2010 12:12 PM

View 4 Replies!   View Related
Dropdown List Selected Index?
i have dropdown list (ITEM TEMPLATE) of grid view , where the values are loaded from db which is (restaurant name). and i have othr field called price .

where each restaurant have diff price values , The below eg ll discribe my criteria . i had set autopostback="true"


fid resname(dropdown list) price

1 resname1 15 //// this should be displayed first , on selecting resname2 the price value should change according to its resname2
but the output is
fid resname price
1 resname1 (empty)blank field

this s d code ,

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
string constr = ConfigurationManager.AppSettings["constring"];
SqlConnection myconnection = new SqlConnection(constr);
DropDownList currentDDL = (DropDownList)sender;
string restaurantname = currentDDL.SelectedValue.ToString();
SqlCommand price = new SqlCommand("select price from maintable where rid='" + restaurantname + "'", myconnection);
SqlDataAdapter value_price = new SqlDataAdapter(price);
DataSet ds1 = new DataSet();
value_price.Fill(ds1, "Table");
TableCell cell = (TableCell)currentDDL.Parent;
cell.Text =(string)ds1.Tables[0].Rows[0][0];
<asp:GridView ID="GridView1" runat="server" style="left: 157px; position: relative; top: 141px" OnRowDataBound="GridView1_RowDataBound" AutoGenerateColumns="False" >
<asp:BoundField DataField="fid" HeaderText="fid" />
<asp:BoundField HeaderText="Fname" DataField="fname"/>
<asp:TemplateField HeaderText="rname">
<asp:DropDownList ID="DropDownList1" AutoPostBack="true" runat="server" Style="position: relative" >
<asp:BoundField HeaderText="price" />
<asp:TemplateField HeaderText="Quantity">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" Style="position: relative"></asp:TextBox>
<asp:ButtonField CommandName="addcart" HeaderText="ADDCART" Text="Button" />

Posted: Nov 03, 2008 09:25 AM

View 1 Replies!   View Related
Trying To Get Selected Value Of A Html Dropdown List
How can I get the selected value of a HTML dropdown list using 2.0 (VB). I know I have done something like this before, but can't find that code.

Here is my HTML list

<select id="a2"><option>1</option><option>2</option><option>3</option><option>4</option><option>5</option></select>

Posted: Dec 11, 2010 02:56 AM

View 5 Replies!   View Related
Web Forms :: Preselect Item In Dropdown List Box Based On Value
I am trying topreselect an item in a drop down list box based upon a value I pass in from a data reader. When Iplace a "Watch" on the drop down list box, the code I am listing belowsays that it does what it is supposed to and sets the "selected item" to the one I want BUT when the page is rendered and comes up the first item is always selected.It is like it loses the set when the page is loaded or something.

Here is the code....
<td style="width:33%"><asp:Label CssClass="formlabel" ID="lblRU" runat="server" Text="Reporting Unit: "> </asp:Label> <asp:DropDownList ID="ddlRepUnitTeam" runat="server"DataSourceID="SqlDataSource1" DataValueField="MR_LU_TEAMS_PK" DataTextField="MR_LU_TEAMS_NAME"> </asp:DropDownList> </td> <%
For Each item As ListItem In ddlRepUnitTeam.Items
If item.Text = myReader.GetString(0) Then ' ddlRepUnitTeam.Visible = False
item.Selected = True Exit For End If Next %>

For giggles, I add the ".Visible = False" in there as a test and commented it out later. That doesnt work either. The item still is visible. I know the IF statement passes as it enters into the if statement using debug mode and hits the "Exit For" so I know the condition is being met. I am at a loss over this one.

Posted: Jun 16, 2010 08:48 PM

View 8 Replies!   View Related
Web Forms :: Dropdown List With No Item Selected
I have a drop down list that loads and has the first item [0] selected.I tried setting the selected index to -1 but it still shows as 0. Is there any way to have it so none of the items in the drop down list are selected so that it will force the user to select one?Here is the code for binding the data from the database:

DA_Class DAobject = new DA_Class();
ddl.DataSource = DAobject.GetItems();
ddl.DataTextField = "Description";
ddl.DataValueField = "ID";
ddl.SelectedIndex = -1;

Posted: Oct 19, 2009 02:07 PM

View 5 Replies!   View Related
Web Forms :: Selected Value Not Getting Displayed In Dropdown List?
I have an aspx page that contains a drop down list that contains the listof countries.

i also have a button on the page for post back purposes.

when i click the button,i want to change the selected value of the drop down list that should be displayed on the postback in the dropdown list as the 0 index.

The value is getting selected as i can check througha label control but the selected value is not getting displayed at the 0 index as it should be.kindly let me know how i can i display the selected value at 0 index on the post back.


Posted: Dec 29, 2009 11:26 AM

View 4 Replies!   View Related
C# - Cant Set Dropdown List Selected Value In Page Load
I'm trying to set the selected value of a ddl during page load ie. before databind.

This causes "selected value does not exist" errors. So I force a databind, and add a new element if it does not exist in the data source.

However it looks like when the databind is performed later in the page lifecycle that my added element(s) are removed/overwritten.

Am I setting the values in the wrong part of the life cycle?

Posted: Jun 3 10 at 4:31

View 4 Replies!   View Related
C# - Dropdown List Selected Item Always Set To Default Value
I wish to pass values of the selected items into a database and however noticed that the selected item is not what is sent into the database you can see in the snap shot below. during run time the following value is recorded. Where did it all go wrong with the dropdown lists selected item? Counting on your intelligence.

Posted: Jan 17 at 18:37

View 3 Replies!   View Related
Dropdown List Not Saving The Selected Value To Database
In the following code i want to save the value selected by user from drop downlist into database. but whatever value is selected by user, first value of dropdown lsit is saved to database

<% =Html.DropDownList("lstUsertype", (SelectList)ViewData["UserTypeID"])%>
public ActionResult CreateUser()
UmUser _UmUser = new UmUser();
UMRepository _UMRepository = new UMRepository();
EvoLetDataContext db = new EvoLetDataContext();
ViewData["UserTypeID"] = new SelectList(_UMRepository.FillUserTypes(), "UserTypeID", "UserType",2);
return View(_UmUser);
public ActionResult CreateUser(UmUser _umUser)
if (ModelState.IsValid)
UserRepository _UserRepository = new UserRepository();
return RedirectToAction("Details", new { id = _umUser.UserID });
return View();
return View();

Posted: May 3 10 at 9:49

View 1 Replies!   View Related
MVC :: Database Not Updating With Dropdown List Selected Value
I have a dropdown list which I am populating using the following code:


Fitter: <%--<%= Html.TextBox("Fitter", Model.Fitter)%>--%> <%= Html.DropDownList("Fitter", Model.Fitter)%> <%= Html.ValidationMessage("Fitter", "*")%>

Posted: Mar 18, 2010 10:34 PM

View 9 Replies!   View Related
Copyright 2005-08, All rights reserved