.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

Get the Display Name of a dropdown into a text box

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

I have created a dropdown control and a text box control in my infopath form. I am binding some values to the dropdown control from a sql database with "value" field as "@ID" and "Display name" as "@Name"

Now, when the user select the dropdown the display name should be auto-populated in the textbox I created, not the "@ID" value.

How to achieve this.

View Complete Post

More Related Resource Links

ActiveX and Visual Basic: Enhance the Display of Long Text Strings in a Combobox or Listbox


The combobox and listbox controls in Visual Basic have no built-in support for displaying text strings that are too long to fit in the visible area of either control. This article describes several techniques to improve the readability of long strings in each control. The first technique uses tooltips to display a combobox or listbox item. The other techniques, which use various Windows APIs, include adding a horizontal scrollbar for a listbox and determining the necessary width of the longest string given the font attributes of the text. The required steps are described for both comboboxes and listboxes.

John Calvert

MSDN Magazine December 2000

How to use display Text in Hyperlink For SharePoint 2010 Designer Workflow


In SharePoint 2007 Designer, I have used the Hyperlink column to store the link "http://www.sharepoint.com/Default.aspx, Details". The details text will be shown in the Hyperlink column. Everything works fine in sharepoint 2007 Designer workflow.

In SharePoint Designer 2010 Workflow, I used the same method but the hyperlink column is displaying the full text "http://www.sharepoint.com/Default.aspx, Details" instead of only Details


how to hide/display controls in NewForm.aspx based on dropdown value in SharePoint list



I have 1 dropdown in my sharepoint list with other columns. If dropdown value equal to 'xyz' i need to display some other controls, otherwise these controls should be hidden.

I know we can achieve this with javascript. If any one can provide code or sample then it will be appreciated. or is there any other alternative methods to do this ........

Thanks & Regards, Neerubee

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,

How to display multiline text in ECT formview?

Hello, with SPD i created External Content Type from MSSQL database. How to customize SharePoint:FormField in dispform.aspx to display multiline text from database? I tried use NoteField insted, but it trows excepion. BR  

Choose Item from dropdown list and display in a separate URL ASP.NET

Hi, I've a dropdown list for departments (engineering, bio, chemistry,physics etc.) when somebody choose the departments from the dropdown list, it displays the opening closing time(hours) in a detailsview controls. I have separate homepage for these departments ( these are the static html pages and no way to send querystring value) and I want to link the hours for each department from the departmental homepage. When I choose the department from the DDL, everytime it's the same URL. How can I solve the problem  So that I can point the respective hours from the respective departments ?   Thanks in advance.    

Display each new line of a sharepoint mutliline text field as choice in drop down box.

The question pretty much says it all. I have a lot of data I need to represent, and this would be the best way to do it. I have a multiline text field in sharepoint, where each line has a choice that should be a seperate choice in a text box. How do I do this? I have the data connection set up, and I would be fine with adding some sort of tag after each line, if that would make it so infopath can somehow parse out those tags, and interpret each "chunk" as a choice. Thanks in advance for your help.

How to get text value of dropdown list box by passing index value


how to get text value of dropdown list box by its index.

i want to read the ddlproject.selectedindex = 0's text and assign it to a variable strProject.


Thank you very much for the helpful info.

how to refresh display label.text under for loop condition


Dear All,

I have a for loop condition as below coding for looping to change word on label.text, but as a result, it just only display the last value.

pls help me how can I do to display each value for a looping.

i want the result is the label1.text to show 1 then 2, then 3, then 4.......finally is 10.

for i as integer = 0 to 10

   label1.text = i


thx all



ListViewSubItem: Display End of Text Instead of Beginning?



in the case the ColumnHeader's width is too small, is it possible to not show the beginning of the SubItem's text (ending with "..."), but the end of the text, starting with "..."?


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:


display the selected value in dropdown frm DB


this is with ref & continuation of post http://forums.asp.net/t/1612073.aspx

in which day drop is dynamicalluy populated at run time based on the month selected

the values selected are stored in the database.

suppose the user selects NOV 22 of the current year

when the user want to rertive the same stored data i need NOV in month dropdown & 22 in day dropdown

i get the month correctly but day dropdown is balnk


Display Binary PDf in HTML/Text



I am saving user uploaded PDF files in SQL server using varbinary datatype. There is totally no problem in saving in binary and retrieving in PDF. But due to one specific requirement (which i cant change) i to need to fetch binary PDF and display in HTML or atleast get in string form.

Is it possible? If yes how.

Rite now i m opening PDF files like code written below. But it opens a PDF reader in browser. I want to display the data of PDF in plain text instead in PDF reader.

bytedata = (byte[])dsPrograms.Tables[0].Rows[0]["PDFFile"];
                PdfReader pdfReader = new PdfReader(bytedata);
                Response.ContentType = "application/pdf";
                PdfStamper pdfStamper = new PdfStamper(pdfReader, Response.OutputStream, '\0', true);
                AcroFields pdfFormFields = pdfStamper.AcroFields;
                AcroFields docFields = pdfStamper.AcroFields;
                pdfStamper.FormFlattening = false;

on dropdown selection label display respected value inside gridview



Here i am using dropdown that will retrive from database when i will select an item from dropdownlist then item rate display on the selection of dropdown item name.

how will do this???


ContentResult type="text/xml" - IE cannot display this feed


When I return a ContentResult that is ContentType="text/xml" I get an error in the browser - Internet Explorer cannot display this feed.

What would be in the XML that is triggering IE to think it is a feed, and how do I tell IE to not think such things?

When I set Content to contain only the first, 2nd and last line of the XML stream, it renders correctly as XML.


Here is my code:

    public ContentResult InventoryFeed()
        ContentResult cr = new ContentResult();
        cr.Content = System.IO.File.ReadAllText("c:\\downloads\\amazon\\response.txt");
        cr.ContentType = "text/xml";
        return cr;


And here is the XML: 

<?xml version="1.0"?>

<GetFeedSubmissionListResponse xmlns="http://mws.amazonaws.com/doc/2009-01-01/">

asp dropdown - onchange="javascript: select_country(this.options[this.selectedIndex].text);"


With a regular form drop-down box I can use the onchange event to fire off some javascript with out a page refresh or postback to the server. The above code is not working with an asp drop-down control. Is there a way to make this work? 

I have form that hides and shows different textboxes depending on selected values in a dorp-down but it does cause a postback which refreses the screen I want to do this wiithout refreshing the screen and figured Javascript and hide and show divs etc would work.

<script type="text/javascript" language="javascript">
function select_country(selectedcountry)
var country = selectedcountry;

if(country == "United States")
//do nothing;
// hide state drop-down and the state label.
// code goes here...............
} } </script>

The drop-down:

<asp:DropDownList ID

Grab text from dropdown listbox?


Every time I chage the listbox I want to text in the listbox to display on a seprate label on my form. I have used this:

lblTreatment.Text = ddlTreatment.SelectedItem.Text

in the selectedIndexChanged and it works, but I want to select the text when the page first loads up. When I put it in the page_Load I get this error:

Object reference not set to an instance of an object.

And this error is for the code above. Any help?

Thank You

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