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

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

How to bind the selectedvalue from asp.net dropdownlist to list

Posted By:      Posted Date: December 04, 2010    Points: 0   Category :SharePoint


Sharepoint Designer 2007:

How can i bing data from asp.net contorl dropdownlist (selectedvalue) to list.

Thank you

View Complete Post

More Related Resource Links

How to bind a List of hybriddictionay to the dropdownlist

I have a List<HybridDictionary> _Reasons.I need to bind the list to a dropdown. I tried the code as try            {                this.ddlReason.DataSource = _Reasons;                ddlReason.DataValueField = "Key";                ddlReason.DataTextField = "Value";                this.ddlReason.DataBind();                           }            catch            {                //Log Entry            }            finally            {             } But it not work.Please sugges

'Dropdownlist' has a SelectedValue which is invalid because it does not exist in the list of items


I have a dropdown list that has a bind on it and I get this error. Why am I getting this error and what can I do to fix it. here is the code for the dropdown I currently have:


 <asp:DropDownList  ID="DDLPreferred" AppendDataBoundItems="true" SelectedValue='<%# Bind("PREFERRED_COMMUNICATION") %>'  runat="server" TabIndex="15">
                <asp:ListItem Text="none" Value=""></asp:ListItem>

				<asp:ListItem>Home Phone</asp:ListItem>
				<asp:ListItem>Work Phone</asp:ListItem>
				<asp:ListItem>Cell Phone</asp:ListItem>


Dropdownlist error: SelectedValue which is invalid because it does not exist in the list of items.


I have a dropdownlist in a detailsview edit Item template. Also I have two tables - Employee and Main. In the Employee table I have column EmpId and AssignedTo. In the main table I have EmpId which is connected to the Employee table. 

The detailsView has a label which shows the AssignedTo name for a particular record and it works fine. But if I click the edit button to shwo the dropdownlist in the editItemTemplate it is givig me the above error.

The code is:

<asp:DetailsView ID="dtvAssign" runat="server" AutoGenerateRows

How to bind GridView and DropDownList controls using DataTable object

In .net framework 2.0, you can load a DataTable in memory by consuming a data source using a DataReader. In this version you will find the flexibility in accessing the DataReader means write access code once and use again and again using DataReader. To see the functionality of DataTable consider an example that is created using VS2005.

How to bind TemplateField DropDownList with ArrayList?


Hi Expert!

  I'm trying gridview templateField DropDownList bind with arraylist. When i set bindsource i got this error. "//Error Object reference not set to an instance of an object."

My Sample .aspx

<asp:TemplateField HeaderText="Type">
                        <asp:DropDownList ID="_grvcboType" runat="server" Width="117px" DataTextField="Display" DataValueField="Value">
                        <asp:Label ID="Label7" runat="ser

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

bind values to dropdownlist using ASP.NET MVC



I'm using asp.net MVC 2.0, my controller coding is,

foreach(DataColumn dc in dtImport.Columns)


TempData["drpsku"] = dc.ColumnName.ToString();


i need to bind this value to the drpdown list in the aspx page.

<asp:DropDownList ID="DropDownList1" runat="server"></asp

Need to remove databinding of DropdownList when another dropdown list changes


I have many controls on my form, but in particular, I have 2 dropdownlists.  1 dropdown list has 2 values, and each value controls what the second dropdownlist displays.  This is an edititemtemplate and both dropdowns have the selecteditem set via '<%# Bind("fieldname") #>' on page load.  

THe problem is, if I change the value of the first dropdown, it errors out because the second dropdwon has a bound value that is no longer acceptable. 

Can I cancel the bind of the second control, if the the first one is changed?  I would like to cancel the bind, and update the values by using a different datasource depending on the value of the first dropdown or hardcode the new values.



If Dropdown1 has a value of "A" for example Dropdown 2 Shows Values "1", "2", "3"

If Dropdown 1 has a value of "B" , Dropdown2 Shows Values "4", "5", "6".

It binds fine initially, but if I change Dropdown1 from A to B, I want Dropdown2 to show the new values, maybe with a default of "Select an Item" and not error out b/c it's attempts to bind a value of 1, 2, or 3.


Hope this makes sence, b/c I'm

bind drop down list in content page from value from master page

Hi all, I have applied nested master page to some page. Now i want to bind drop downlist from value selected in dropdown list in master page of master applied to that page. the hierarchy of pages is  mypage.aspx -> main.aspx -> inner.master I want bind dropdown list in  mypage.aspx from  from value selected in dropdown list in  inner.master Please help me. 

ListItem Dynamic DropDownList based on custom list entries.

I utilized the following solution to get the drop down list on the page and populate it dynamically, but it doesn't save the selected value back to the SPListItem object. Does anyone have a better solution possibly for this? http://geekswithblogs.net/SoYouKnow/archive/2010/01/21/sharepoint-populating-drop-down-list-field-with-data-from-different.aspx

Bind List&lt;&gt; to GridView

Can any body help how to update list through gridview

Html.DropDownList using a List

This has to be a simple thing, but for whatever reason, I'm just not finding it. I want to use the HTML Helper function to create a DropDownList based on a List<string> (and actually have it bind to the data field on the model).  The simplest example, I suppose, would be: <%: Html.DropDownList("Material", new SelectList(new[] {"Wood","Brick","Metal"})) %> This creates the items in the drop-down, but of course, there's nothing in this line that would bind it to my model (model.Material).  I've done drop-downs with collections of models, where you can bind the Data and Display attributes to properties of the class, but I don't have a class here, just a List. Any ideas?

DropDownList - .SelectedValue Not Changing



I have many dropdownlists in my application, and have never had a problem binding the data to them and setting the selectedvalue.  The ddl is in a DataGrid, and I look for the value in a label control and set the .SelectedValue to that.  I actually copied my code from a different page in my application that functions exactly the same way, except on the "original" page the .SelectedValue changes as expected.  On the "new" page I can see that the Value in the label control in the datagrid has the expected value, and as I step through the code everything is just fine until I hit the .SelectedValue = NewValue.  I can see that the current .SelectedValue is populated with the default value from the databinding, and that the NewValue has the new value I want, but after I step over that statement, the .SelectValue remains what it was as the default value.  So, here is the code:


Protected Sub dgWatchList_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)

Dim ddlAuditor As System.Web.UI.WebControls.DropDownList
Dim AuditorID As Integer
If e.Item.DataSetIndex >= 0 Then

            AuditorID = CType(e.Item.FindControl("lblAuditor"), Label).Text
            ddlAuditor = e.Item.FindControl("ddlAuditor&

How to bind two different list to dropdown base on radiobutton selection

  I have radio button and dropdown column types in sharepoint list, and apart from this i have two list. I want to bind the data to data from the two list base on the selection of radio button. If i select 'Yes' i want to bind from the one of two list, and when i select i want to bind it to another list. Is it possible in sharepoint ?. If yes can you help me out in this

cannot bind dropdownlist inside from button click inside updatepanel



I have a gridview inside UpdatePanel. 

Inside gridview there is a dropdownlist and a button on each row. On button click I am opening a panel through Modal popup extneder.

Inside that pop up there is again a dropdownlist. I am adding an item into this dropdownlist based on the selection from the dropdown inside gridview. 

like  ddl.items.insert(0,'xyz');

But first time this inserted item is not getting reflected in the dropdownlist. But after one postback this item is getting reflected.

Please let me know how to fix this. I tried UpdateMode conditional and always but didn't worked. If I am not clear let me know.


how to bind object data source with bullited list


 i wanted to retrieve things from the data base and perform mathmatical operations on it then post it to the user, so i was told to use the bullited list and bind it to the object dataSource

how to perform such thing??

Bind Event Receiver to List Dynamically


Hey all, I've been working on a little application page that will give users the option to say whether a list should allow duplicate title entries.

I am able to pass the current list GUID to the application page using this:

<UrlAction Url="~site/_layouts/preventduplicates.aspx?List={ListId}"/>

within a custom action which I've added to the list settings. I'm kind of stuck now....


I'm not sure how to grab this GUID out of the url, and use it so I can bind the current list with my event receiver. Every example I've seen of binding has used a hard coded list name which is fine as an example, but isn't the best for real applications. Or is there a way to use the GUID to get the lists name which I can then pass to the spweb.Lists[var] ? Since I won't know the list name beforehand.

Hope all of that makes sense, any suggestions are appreciated.

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