.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

how can i display the selected value of dropdownlist from edittemplate to label from itemtemplate?

Posted By:      Posted Date: August 26, 2010    Points: 0   Category :SharePoint

I have a detailsview with a dropdownlist in it. the detailsview is connected to a database table(employees having the following fields: id-smallint,name-nvarchar, departmnet-smallint). the ddl is connected to another table (departments with the following fields: id-smallint, departmentName-nvarchar). the ddl is in the edititemTempalte of the department field. My goal is to display in  the itemtemplate the departmentName (the selected value from the edititemtemplate ). How can I do this? Doyou have any ideas?

thanks a lot

View Complete Post

More Related Resource Links

C# data bound combobox: display selected item text in separate label.content


I am new to C# but I'm resisting the urge to run screaming back to VB.NET. I'm working with a WPF application using C# code-behind and a lot of binding to a SQL 2005 database backend.

GOAL: I have a comboBox bound to a tbl_Systems entity which provides a list of systems for user selection. When the User selects a system from the comboBox I want to display the selection's text in a separate Label. The big picture is that several comboBox selections will be used to build a query string that will populate a listbox. So, I want to display these selected values in the Label so the user can see the query string they have dictated.

PROBLEM: When I set the Label content property to the comboBox SelectedItem property the entity tbl_System is displayed in the Label not the comboBox selection text.

SUSPICION: From reading similar examples in VB I suspect that the comboBox SelectedItem is actually a "datarowview" or the C# equivalent. But I don't know how to translate this explanation to C#.

The UI XAML comboBox properties are set as such:


Show asp:Label from dropdownlist in itemtemplate


Noob working in C# / VS2010.

I have a dropdownlist - ddlGroupName.  Next to it, I have a Label - lblGroupName. 

The dropdownlist is bound to an SQL table, and displays the appropriate group depending on the primary key (contracters, suppliers, etc etc). 

When the page loads, I want the Label to display whatever is in the dropdownlist, then I can hide the dropdownlist and am just left with the label.

I was using "lblGroupName.Text = ddlGroupName.SelectedItem.Text;", but intellisense doesn't seem to acknowledge the controls when they're in an ItemTemplate. 

Any guidance would be very much appreciated....Thank you

How to display a count of search results with keywords in a label?


Sorry for a basic post here; I am very new to VB!

I am currently building a search page, which includes a textbox and two drop-down lists, a search button, and a datagrid. If results are found and displayed, I would like a label to display:

(e.g.) "24 results found for 'blue sky clouds' "

...where the integer represents the results count, and the keywords and/or drop-down list selections are included in the string.

If no results are found I would like the label to display:

(e.g.) "No results were found that match your selection. Please try again"

I would also like the label to be invisible until a search occurs.

Thanks in advance!

Sharepoint list group by column data ,display in webcontrol like panel or label


I  have a sharepoint list[Managers] with groupby sector column. like below




Each Sector group by column data i want to display in label or panel control.

How to do that ? how to write the logic?



Regards, Mansoor

setting label using modalpopup selected value


Hi all:

I have a modalpopup control which has  a gridview and search criteria. User selects a records and clicks modalpopup ok button ( which is set as modalpopup's okbutton). I have attached an event to okbutton click event. and inside this event, I am setting a label control which in on main page which called this modalpopup. I debugged code, it comes inside that event but doesnt set value. below is my event code.

protected void btnOkCustomers_Click(object sender, EventArgs e)


Int32 CustomerID = Convert.ToInt32(GridView2.SelectedDataKey.Value);

orders = new Orders();

DataSet CustomersDs = orders.GetCustomerById(CustomerID);

lblCustomerName.Text = "sadasdad"; // CustomersDs.Tables[0].Rows[0]["first_name"].ToString();




Please suggest me solution to this.

Asif Hameed

DropDownList to display values from Two Tables - bold sub heading and normal Text

Hello I hope I am not asking simple one.  SUPPORT SERVICES<     Computing Service    Library or Data Engineering    Civil Engineering    Electrical Engineering  I have the data to display in a DropDownList control shown as above. There is a distinct category Type(example Support Services) and Category Name i.e., Computing Services. I do not want to hard code the values into DropDownList control. I like to get the data from database to display as shown in above Table. Note that Category Type should be displayed in Bold and Category Name in normal Text. Question: In order to achieve the above, 1. How many database Tables and relationships between them  2. Query the data to display in the above format in drop down 3. how should be the code behind i.e, DataTextValue and DataValueField for DropDownList. Please provide with useful code snippets or references. Thanks,

dropdownlist - default value is not 'selected value'

i have created a dropdown list that is populated from a sqlserver datasource. i have a separate sql command which uses the dropdownlist.selected value as a parameter and returns the command value to a label.  it mostly works fine but with one problem. when the page loads, the label value is null, because it doesn't seem to treat the dropdownlist default value as a selected value. when i use the dropdownlist to select a value, this is fine and the label begins to display the expected value. is there anyway I can make the default value when the page is loaded act like a manually selected value, so the label control never displays a null value?

ASP.Net MVC Dropdownlist and selected value problem

I was able to create a dropdownlist for my MVC project, but the value is not selected as  selected value on the dropdownlist. It just shows whole county list from the first.The value is from database. I tried find it from previous post, but it was quite confusing. Please, suggest me for any idea. Controller Code public ActionResult Edit(int i) {      var items = new SelectList(db.MST_COUNTRies.ToList(), "COUNTRY_ID", "COUNTRY_NM");      ViewData["MST_COUNTRies"] = items; } View Code <p>     <%= Html.DropDownList("COUNTRY_ID", (SelectList)ViewData["MST_COUNTRies"])%> </P>I was able to create a dropdownlist for my MVC project, but the value is not selected as  selected value on the dropdownlist. It just shows whole county list from the first.The value is from database. I tried find it from previous post, but it was quite confusing. Please, suggest me for any idea.Controller Codepublic ActionResult Edit(int i){     var items = new SelectList(db.MST_COUNTRies.ToList(), "COUNTRY_ID", "COUNTRY_NM");     ViewData["MST_COUNTRies"] = items;}View Code<p>    <%= Html.DropDownList("COUNTRY_ID", (SelectList)ViewData["MST_COUNTRies"])%></P>

How to display images with label object

HelloI want to display image with asp:label, I also want to display message in two lines in which first line with 12 pt size and second line with 11 pt.I am using asp.net with C#.Please adviseAvi

Multivalue parameters - Changing label if (Select All) is selected

I'm using SSRS 2005.  I have a report which has a multi value parameter.  When you click (Select All) the text in the parameter combobox shows all the names of the possible values.  Since this is my default it really looks tacky and hard to read. Is there a way I can have the text in the multi value parameter combobox say "ALL" or something else when (Select All) is checked?  

Fill a Listbox with value selected from a Dropdownlist

Hi, Maybe the question has already be posted, but I didn't find it.I have in my web page two controls: a dropdownlist and a listboxMy goal is to fill the listbox with values from my database depending on what I have selected in my dropdownlist.I wouldlike to use the CascadingDropDown component for that. Is that possible ??(I tried on my own and I get this error messageException Details: System.InvalidCastException: Unable to cast object of type 'System.Web.UI.WebControls.ListBox' to type 'System.Web.UI.WebControls.DropDownList'.I think it's when i tried to fill the listbox with this function:[WebMethod] public CascadingDropDownNameValue[] GetAppliForDomain(string knownCategoryValues, string category) { int domainID; //this stringdictionary contains has table with key value pair of country and countryID StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues); if (!kv.ContainsKey("Domain") || !Int32.TryParse(kv["Domain"], out domainID)) { throw new ArgumentException("Couldn't find Domain."); }; SqlConnection con = new SqlConnection(strConnection); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = System.Data.CommandType.Text

MultiColumn Combo Box Does not display selected value

Hi, I have a WPF MultiColumn Combo Box in a WPF DataGrid Code :     <my:DataGridComboBoxColumn Header="Address" Width="200" x:Name="dgColContactAddr"   SelectedValuePath="CompleteAddr">       <my:DataGridComboBoxColumn.EditingElementStyle>     <Style x:Name="styel1" TargetType="{x:Type ComboBox}">     <Setter Property="ItemsControl.ItemTemplate" >     <Setter.Value>     <DataTemplate>     <StackPanel Orientation="Horizontal">     <TextBlock Text="{Binding Path=Address1}" />     <TextBlock Text=" "/>     <TextBlock Text="{Binding Path=Address2}"/>     <TextBlock Text=", "/>     <TextBlock Text="{Binding Path=City}"/>     <TextBlock Text=", "/>     <TextBlock Text="{Binding Path=State}"/>     <TextBlock Text=", "/>     <TextBlock Text="{Binding Path=Country}"/>     </StackPanel>     </DataTemplate>       </Setter.Value>

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?

Fetching DropDownList Selected Value

I'm having issues getting the selecteditems and value after Databinding a dropdown list.  I have a button event with dropdownlist2.Selecteditem.text, but will always get the "-- Select --" as the SelectedItem.text ?  Anybody know why this is happening ?   Dim conn As New SqlConnection '("xxxxxx") conn.ConnectionString = ConfigurationManager.ConnectionStrings("PostAdSqlServer").ToString Dim query As String = ("SELECT [CategoryId], [Name] FROM [Category]") Dim cmd As New SqlCommand(query, conn) cmd.Connection.Open() Dim ddlValues As SqlDataReader ddlValues = cmd.ExecuteReader() DropDownList2.DataSource = ddlValues DropDownList2.DataValueField = "CategoryId" DropDownList2.DataTextField = "Name" DropDownList2.DataBind() DropDownList2.Items.Insert(0, "-- Select --") cmd.Connection.Close() cmd.Connection.Dispose()    

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 ???

Selected Option from dropdownlist

 I need to figure out a way to modify the style property of a div on my page so that when a certain item ("Not shown - please quote") on a few different dropdownlists are selected,  the div style is set to "display: none". The dropdownlist gets generated dynamically and the amount of dropdownlists varys for each product. I've named the class via the cssclass property in the dropdownlist template usercontrol to be "dropDownClass".Here is my code for this page: <div id="ProductControls"> <div id="ProductOptions"> <div id="ctl00_MainContentHolder_VariantsDisplay_VariantsPanel" class="variantsdisplay"> <table> <tr class="dropdownlist"> <td class="choicelabel"><span id="ctl00_MainContentHolder_VariantsDisplay_modifierTemplate1_InputLabel">Color</span></td> <td class="choicefield"><select name="ctl00$MainContentHolder$VariantsDisplay$modifierTemplate1$ModifierList" onchange="javascript:setTimeout('__doPostBack(\'ctl00$MainContentHolder$VariantsDisplay$modifierTemplate1$ModifierList\',\'\')', 0)" id="ctl00_MainContentHolder_VariantsDisplay_modifierTemplate1_ModifierList" clas

How to Capture a DropDownList Selected Index Change Event

I have a gridview that receives data based on selection from a primary dropdownlist object. Works. Within the gridview, there is a dropdownlist whose selected index is based on the query from the primary dropdownlist. Works. Problem. How do I force the used to  change whatever value that the dropdownlist contains after they make their initial selection from the primary dropdownlist; except the default value of "Please make a selection". Gridview, contains a checkbox which drives whether a selected row is inserted into the data base. The databind in done using an ObjectDataSource on the presentation page, not in the code behind.   Thank you.   Ayomide 
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