Tracking Forums, Newsgroups, Maling Lists
Home Submit Tracker Forums
  Advanced Search
  HOME    TRACKER    ASP.NET


Advertisements:










How To Select Default Value In Dropdown List Using JQuery


I want to select "Algeria" as default selected value in drop down list.I am fetching countrylist from database using handler ( LoadCountryList.ashx ) in JSON data format and binding it to dropdownlist on aspx page using Jquery's $.getJSON precedure given below

[code]...


View 3 Replies (Posted: Feb 12 at 5:27)

Sponsored Links:

Related Forum Messages For ASP.NET category:
Web Forms :: How To Get A Default Value From Dropdown List That Contains Values From A SQL Select Statement
I want to have a default value/item of "---Select One---" and then list all of the values from the SQL statement. Currently I am having trouble doing this. I tried to add it to the List Item but it doesn't show on the page.

Posted: Sep 27, 2010 01:07 PM

View 25 Replies!   View Related
Web Forms :: Multi Select Dropdown List With A Limit To Select Only 3 Values?
I am creating an asp.net web application using c#. where in one of the requirements is creating

a multiple selection DDL but with the ability to select only 3 values out of all the values displayed in the dropdown.

Posted: Dec 02, 2009 01:49 PM

View 4 Replies!   View Related
Forms Data Controls :: Select Last Date In DropDown By Default?
I have a date list in DropDown and there is no blank item in it.Dropdown item seems to be following:

01-02-2010
02-02-2010
03-02-2010
04-02-2010

DropDown is bounded by sqlDataSource.

If04-02-2010 is the last date for today then I want to display04-02-2010by default in the dropdown if the page load.

We are updating data on daily basis. So on next day the date will be 05-02-2010 so when the data updated then 05-02-2010 should be shown iby default in the dropdown.

Posted: Feb 24, 2010 07:50 AM

View 4 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:

[Code]....

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
Dropdown List Always Sticks To Default Value?
I am trying to save a drop down list box selected value but on submit everytime i check it gets default value although i change the selection... i have checked in the html source to make sure if it is getting different values and thats fine.. I have also onselectedindexchange event to change another value... i dont know y after changing the value it goes back to its default value...

Posted: Jan 27, 2009 11:30 PM

View 3 Replies!   View Related
Web Forms :: Default Value Of Dropdown List?
I have a DropDownList that is bound to sql datasource . Howcan iset itsdefault valueto Null and change its value to one of its items programmicaly.

Posted: Sep 21, 2010 03:00 PM

View 3 Replies!   View Related
Web Forms :: Not Able To Get The Value For A Default Option In A Dropdown List?
I am binding data to drop-dwn like this:

[Code]....

I am using this JavaScript function to get the value for a selected option in a ddl:

[Code]....

When I dont select any option inddlSchoolRegion and keep the default option, then I am supposed to get the value0 for a selected option in ddlSchoolRegion as I have set value 0 for the default option ( ddlSchoolRegion.Items.Insert(0, new ListItem("Choose One", "0")); )

I am calling JavaScript functoin:

[Code]....

After executing this statement, SchoolRegion contains 'Choose One' instead of '0'

Posted: Aug 20, 2009 03:08 PM

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
How To Select A Dropdown List Value
I have a dropdownlist ,where one of teh itemtext is "Payment -> Enrollment" and value is not unique'

so for one of teh condition i had to select the item "Payment -> Enrollment", but with teh below code the "Please select option text is changed to this text and finally the dropdown loads with 2 items having "Payment -> Enrollment". I cannot do ddlCategory.SelectedItem.Value as teh value is not unique ,teh value is teh amount which keeps changing .

easy way to select the item "Payment -> Enrollment".

ddlCategory.SelectedItem.Text = "Payment -> Enrollment";

Posted: Jan 28, 2011 03:23 AM

View 9 Replies!   View Related
Add ALL In Dropdown List To Select All Record?
I have a datasource that extract 8 fields and one of them is Region that can be US, Europe, Afraica. I have a dropdownlist that get distinct value to get these 3 region from similar datasource built. Now my data is listed and show only data for the region selected in the dropdown list. So far it is very standard. However, now I have a trouble. I want to add to the dropdown list an Option "ALL" so that when selected, all data a shown. How to do this ? I searched around and get no hints.

Posted: Jul 24, 2009 02:57 AM

View 8 Replies!   View Related
Select Last Item In Dropdown List
I have a fairly simple question. I have a drop down list that is populated by a table in my sql database. I want to be able to go to the last record or item in the table and add one to the selected value, then insert that information in a textbox. Getting the selected value is easy, I just don't know how to automatically get the very last record. Since the drop down list is linked to the database, the number of items in the list changes almost daily.

Posted: Jul 24, 2009 04:01 PM

View 2 Replies!   View Related
Select Input Date As Default In JQuery Datepicker?
I have an ASP.NET application which uses JQuery datepicker for picking dates in some text boxes. For some date textboxes, I populate the date textbox from my database. When this textbox is clicked my JQuery datepicker appears, and it shows the current month with Today highlighted. This is fine for empty textboxes, however sometimes the text box is populated from the database. When the textbox is not empty I want the datepicker to show the textbox month and have the selected date to be the textbox date. Here's my current javascript code in my asp.net script header:

<script type="text/javascript">
$(function () {
$('#myTextBox').datepicker({
dateFormat: 'dd-M-yy',
numberOfMonths: 2,
autoSize: true,
changeMonth: true,
changeYear: true,
showButtonPanel: true,
maxDate: 0
});
});
</script>

Posted: Nov 17 10 at 9:19

View 2 Replies!   View Related
DropDownList / HTML Select List Default Selection?
For my ASP.NET page, in the code behind I load various items/options into a DropDownList but I do not set a default by assigning SelectedIndex. I notice for the postback SelectedIndex is set to 0, even if I never set focus to or changed the value in the DropDownList.

If not otherwise specified in the code behind or markup, will a default value of 0 be used for the SelectedIndex in a postback with a DropDownList? If yes, is this part of the HTML standard for selection lists, or is this just the way it is implemented for ASP.NET?

Posted: Jul 18 10 at 18:53

View 1 Replies!   View Related
Web Forms :: Dropdown List - Default Value And OnSelectedIndexChanged Doesn't Fire
I have a dropdown list that is populated by a dataset (Data being extracted from DB). Based on the selection made by the user I call OnSelectedIndexChanged, and populated the form with the relevent info.The problem I am having is the first item in the list is selected by default, so if the user selects this option OnSelectedIndexChanged does not fire. To work around this I add a default item to the dropdown list after populating it with the dataset as shown here;

jobStandardActList.Items.Insert(0,
jobStandardActList.SelectedIndex = 0;
jobStandardActList.SelectedValue =
"----Select an Item----");"";

This works fine, however if the user selects an item from the list, and then proceeds to selects the default item "----Select Item----" i receive an error. sys.webforms.pagerequestmanagersevererrorexception: an unknown error occured while processing the request on the server. The status code returned from the server was: 500

Posted: Jun 07, 2010 01:28 AM

View 4 Replies!   View Related
Make Visible Div On Dropdown Select In Jquery?
I am developing the asp.net mvc application . my one of forms requirement is that:

It has dropdown filling up with let say A,B,C values. If selected A then on UI there should be 2 text boxes should be visible and other should be invisible , if selected B, then must be add another 2 text boxes , i this way there should be 4 text boxes. same for selection of C.

I able to get the selected value by

[code]....

What I have to do. I tried hide() show(), but i think it is not working for me.

Posted: Nov 25 10 at 8:11

View 1 Replies!   View Related
Web Forms :: How To Select A Item In Dropdown List
when i select an item in a filled dropdown list ,the select values appears twice in the dropdown list

Posted: Sep 02, 2009 04:30 PM

View 8 Replies!   View Related
Web Forms :: Dropdown List Do Not Select Option
I have a dropdownlist on my page that when a user selects an item sets the list for another dropdownlist. My problem is that no matter what the user selects in the 1st dropdown it resets itself to the first item in the list. I have autopostback=true and nableviewstate= true. Is there another setting i'm missing or is it my code?

[Code...]


Posted: Jan 05, 2011 09:04 AM

View 4 Replies!   View Related
Web Forms :: Dropdown List Does Not Allow To Select Options In Firefox
I have a drop down list with two options Score and status. On selecting scoreselect score i display aMultihandleSliderExtender to select the score rangeex: 10 to 20 and on selecting status idisplay dropdown list . On displaying one option i make the other as not visible.

Now comes the problem in Firefox (works properly in IE) when i select score and then try to change my option to status it does not allow me to do so i.e the mouse over event on the dropdownlist is not working.

Posted: Apr 13, 2010 02:25 PM

View 1 Replies!   View Related
JQuery :: Get Value Of Dropdown List?
I am having problem of getting value from Dropdown List that located in the listview. I want to use the Jquery to get the value of thos Dropdown list and insert that data into the database.

Posted: Mar 17, 2011 07:26 AM

View 3 Replies!   View Related
Web Forms :: How To Make Dropdown List Having Two Features - Select And Input
The dropdown list in asp.net have only one feature: select a value.

How to make dropdown list having two features: select and input?

Posted: Dec 15, 2009 01:12 PM

View 1 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

[Code]....

[Code]....

Posted: Nov 03, 2010 12:12 PM

View 4 Replies!   View Related
Web Forms :: Auto Select Item In DropDown List By Database Result?
I have a DetailsView that binds a User's Profile data into an ItemTemplate upon the Page_Load. When the user chooses Edit Mode, all of the Data is correctly carried over, except for the DropDownLists selected values. If on the ReadOnly page, the user's data shows "Male" for the Sex, then on the edit Mode page, I would like the DropDownList that gets the sexes from the database ("male", "female"), to have automatically selected "Male" in the DropDownList, not the lowest indexed item.

[Code]....

[Code]....

Posted: Nov 06, 2010 06:04 AM

View 3 Replies!   View Related
JQuery :: How To Remove Select In List Box
i crate a list box by database but select is show how to remove this using jquery<td><select name="ListBox1" multiple="multiple" size="8" id="ListBox1">

<option value="">Select</option>
<option value="1001">1001.Ashok</option>
<option value="1002">1002.Rajiv</option>
<option value="1003">1003.Garima</option>
<option value="1012">1012.Akhil</option>
<option value="1011">1011.Nasir</option>
<option value="1006">1006.Ashish</option>
<option value="1004">1004.Tazeen</option>
<option value="1005">1005.Raghav</option>
<option value="1014">1014.Sonal</option>
<option value="1013">1013.Praveen</option>
<option value="1007">1007.Kumud</option>
<option value="1009">1009.Gouda</option>
<option value="1019">1019.Pradeep</option></select>

Posted: Sep 21, 2010 08:12 AM

View 3 Replies!   View Related
Jquery To Add Textbox And Dropdown List Dynamically?
I need to be able provide a table on web page with one row which has a two drop down list and one textbox and the user's should be able to add any number of rows they want. I need to to this using jquery so that i can avoid post back. Is this possible to be done in Jquery and if it is possible i was looking for some example which will be like a pointer

Posted: Aug 20 10 at 15:54

View 1 Replies!   View Related
JQuery :: How To Set The Particular Item As Bold In Dropdown List
my sampe data to be listed in the dropdown

Regional
Area
SubArea
National

the item regional and national should be find in dropdown list and set to be bold. i know how to do this in server side .but i want to do in javascript or jquery

Posted: Mar 03, 2011 08:34 AM

View 3 Replies!   View Related
JQuery :: Getting Value From Dropdown List That Located In The Listview?
Last time I hadproblem in getting value from Dropdown List that located in the listview. I want to use the Jquery to get the value of thos Dropdown list and insert that data into the database,.

This time I have added some more radio buttun that are generated from my SQL server database and I want to use Jquery to get those radio button.

Posted: Mar 18, 2011 03:58 AM

View 2 Replies!   View Related
Forms Data Controls :: "Select All" As Default In Databound Dropdown?
I have a dropdown list which is bound to a gridview.I would like to add a dropdownlist item which, when selected, will default to displaying ALL gridviewrows. So I would likeas the first dropdown list item "All Items" and have this as the default.

Posted: Nov 12, 2010 12:01 AM

View 2 Replies!   View Related
JQuery :: Populate And Create A Select List?
I am developing an MVC application. As part of the functionality I am using jQuery to invoke a server side Action method. This method returns an array of strings. I would like to display the list of strings in a select list using jQuery. e.g. I would like to see the following html:

<select name="CompleteAddress" onchange="Run()" id="CompleteAddress">
<option>22, Random Address</option>
<option>24, Random Address</option>
<option>26, Random Address</option>
</select>

The values "22 Random Address" etc... come from the Action method.

Currently, I am invoking the action method as follows:

[Code]....

Posted: Feb 03, 2011 07:33 PM

View 2 Replies!   View Related
Mvc Jquery Removing Select List Item?
[code]...

i have six items in my select in which 4 of them are add,edit ,delete view, it is multiselect list, i don't want the user to remove the these 4 items , apart from that they can remove any item. how will i do that? it is not happening in the above code

Posted: Jun 5 10 at 7:32

View 2 Replies!   View Related
Jquery - Populating A Select List From An Autocomplete?
selecting a few items from a list of thousands. I have an autocomplete field that searches the db, and returns a name/id pair. This is working fine.

The next step is to preserve the selected IDs, and allow the user to remove some if needed. For this, I've been looking at using a select, and was hoping a UI something like that provided by this, but it doesn't work: it allows you to select items that already exist in the select, but doesn't work with a dynamically created select.

The final step is a traditional postback (using a submit button, this is in asp.net webforms) where I'll need to have access to the final list of IDs.

Posted: Sep 27 10 at 14:25

View 1 Replies!   View Related
Forms Data Controls :: Select Dropdown List Item In Gridview Edit Mode?
I have a dropdown list in the edittemplateof a gridview andnow it selects the first value that comes from the datasource. How can I get it to select it's original value?Where do I put the code?

Posted: Jun 16, 2010 06:58 AM

View 9 Replies!   View Related
Forms Data Controls :: Dropdown Select Message In Item Template Gridview Dropdwon List?
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 goingto second row. I need to remain first row user selected value on going to next row. The New row will show --select-- message..

<asp:DropDownList id="DropDonList2" tabIndex=11 runat="server"

Posted: Sep 18, 2010 06:57 AM

View 6 Replies!   View Related
Jquery - Removing Items From Dropdown List (client Side)
So I have a number of dropdown select list controls populated as part of a repeater. They might contain overlapping data, meaning that the first d d list control will have selections:

a
b
c

Second one:

c
d
e


Third one:

d
e
h

and so on.

So what I would like to do is to srart removing the duplicate items from the reset of drop down controls once the user starts selecting those. I intend to use jQuery for this.

Posted: Feb 10 at 21:03

View 2 Replies!   View Related
Add Record Via Jquery Ajax Call To Webmethod And Update Dropdown List
i manage to add recrod via jquery ajax call to webmethod but i want to update the dropdown list once the record is been added. i dont want to use update panel. what would be the best way of doing that.

Posted: Jan 26 10 at 17:38

View 2 Replies!   View Related
JQuery :: Open Modelpopup Window Based On Value Seleted In Dropdown List?
Is there a way to open modelpopup window based on value seleted in dropdown list?

Posted: May 27, 2010 09:00 PM

View 5 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">
<DeleteParameters>
<asp:Parameter Name="PictureID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<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" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="UserIdValue" Name="UserId" PropertyName="Text"/>
</SelectParameters>
<UpdateParameters>
<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" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
<asp:SqlDataSource ID="categoriesDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [CategoryID], [Name] FROM [Categories] WHERE ([UserId] = @UserId)">
<SelectParameters>
<asp:ControlParameter ControlID="UserIdValue" Name="UserId" PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:SqlDataSource ID="maxPictureIDDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT MAX(PictureID)
FROM Pictures
WHERE UserId = @UserId">
<SelectParameters>
<asp:ControlParameter ControlID="UserIdValue" Name="UserId"
PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>
<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" />
<Fields>
<asp:TemplateField HeaderText="Picture">
<InsertItemTemplate>
<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>
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Category" SortExpression="CategoryID">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("CategoryID") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<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:DropDownList>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("CategoryID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Title" SortExpression="Title">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<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"
ValidationGroup="PictureAdd"></asp:RequiredFieldValidator>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Title") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Description" SortExpression="Description">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Description") %>'

Posted: Oct 10, 2010 07:47 PM

View 2 Replies!   View Related
Page_load Fires Twice For UpdatePanel Refresh Whilst Having A JQuery Bound Change Event On A Dropdown List?
I've tried to wrap up my problem with a complete example below - the original problem is part of a jQuery plug-in that I'm writing to extend the behaviour of an ASP.NET ajax application I already have.

The aspx page below has one drop down list which is marked for auto post back. I've also bound a change event using jquery (which ultimately I will swap for a .live() event to maintain the binding after the update panel refresh.) The problem is, when the jQuery event is bound I see two ajax begin requests and page_loads fire but only one ddlTest_OnselectedIndexChanged event. One of the page loads is malformed too - the content-length states it's about 300 bytes long whilst the totalBytes is 0 and form data empty. This does not happen if I bind to the click event of a button.

why the erroneous page_load event is firing ?

[code]....

Posted: Sep 11 10 at 20:21

View 2 Replies!   View Related
DataSource Controls :: Insert A "Select User" Row In Linq For A Dropdown List?
I'm new to Linq. I have searched and searched the web for a soluion, and can't find anything. I have a Linq query and I want to insert a row ("Select User") to the top before I pass it to the drop down list. I've been trying to use the Union but to now avail (it keeps telling me that my object doesn't support the Union method). My code, prior to attempting to inser a row, is very simple.

public SelectList DropDown_Users()
{
var context = new VivarianDataContext();
var query = from t in context.AspnetUsers
select new { t.UserId, t.LastName };
list = new SelectList(query.AsEnumerable(), "UserId", "LastName");
return list;
}

Now I try to insert a row and I found this on the internet and it seems to say that his solution will work. But it is filled with syntax errors. [URL]

I tried to implement it using the following code, but it doesn't compile.

public SelectList DropDown_Users()
{
SelectList list;
//get the original data
var context = new SQL2005633131VivarianDataContext();
var query = from t in context.AspnetUsers
select new { t.UserId, t.LastName };
//create a dummy table with an empty row
var AllUsers = new List<AspnetUsers>();
var BlankUser = new AspnetUsers()
{UserId=System.Guid.Empty, LastName="Select One"};
AllUsers.Add(BlankUser);
//use Union to join the data - ERRORS HERE
var newTable = AllUsers.Union(query);
list = new SelectList(newTable.AsEnumerable(), "UserId", "LastName");
return list;
}

Posted: Sep 07, 2010 02:47 AM

View 7 Replies!   View Related
Web Forms :: Can't Select Dropdown List Option If There Is Only One Option Returned
I have a dynamic dropdown that is populated from sql. The user is supposed to select an option from the dropdown, then click a search button on the form to return some results based on that selection. It works fine if the dropdown gets populated with more than one record. However, if only one record is returned, that one record can't be selected. Whether you select it or just leave it alone since it's the only one, when you click the form button (search button), no results are returned b/c the dropdown selection must not be actually selected.

I've included the relevant code below. First the DDL, then the datasource, and finally the C# code in the if (!Page.IsPostBack)

[Code]....

Posted: Jun 29, 2010 02:23 PM

View 4 Replies!   View Related
Copyright 2005-08 www.BigResource.com, All rights reserved