dropdown list with 2 data value fields


DropdownList1.DataValueField = "ST_ID_NMBR" + "^" +"STATUS";

Hi,

i need to have 2 values for the datavaluefield of a dropdownlist.

hence i tried teh above statement,but it didnt work.

Can anybody please tell me how to do it.

Thanks

0
poojakulkarni
4/21/2009 3:41:48 AM
asp.net.getting-started 91979 articles. 3 followers. Follow

6 Replies
697 Views

Similar Articles

[PageSpeed] 59

You also could create a extra column in your query 'NMBR_STATUS' where the value of the column is ST_ID_NMBR + SPACE(1) + STATUS and use that NMBR_STATUS to your datavaluefield.

Hope it helps.


Jef Claes
~~~~~~~~~~

Visit my blog
0
Nemesis116
4/21/2009 5:56:46 AM

if you are displaying the data in dropdownlist... change your sqlquery to something like this....

SELECT emp_id, fname + ' ' + lname As empName FROM employees

Select id, ST_ID_NMBR+' '+STATUS As Something From TableName

 


Chinna_sv...
0
getchinna_sv
4/21/2009 5:58:45 AM

Hi,

a sample:

dropdown.datasource = somedatatable;

dropdown.datavaluefield = "column1";

dropdown.databind();

In the above line, what it means is select column1 as datavaluefeild.

in your code:

DropdownList1.DataValueField = "ST_ID_NMBR" + "^" +"STATUS"; -- here string gets concatenated.

the control is searching for a column  "ST_ID_NMBR^STATUS", which is not available in the datasource.

Hope you understand the sample code below:

 

            object[] testRow;

            System.Data.DataTable dt = new DataTable();

            dt.Columns.Add("test 1");

            dt.Columns.Add("test 2");

            dt.Rows.Add(new object[2]{"test", "test"});

            dt.Columns.Add("test 3");

            dt.Rows[0][2] = string.Format("{0}^{1}", dt.Rows[0][0].ToString() , dt.Rows[0][1].ToString());

            testDDL.DataSource = dt;           

            testDDL.DataTextField = "test 3";

            testDDL.DataBind();

 

You have to do something like this to achieve what you want without altering the query.

but altering query is the simplest approach.

 

Regards,

Yoga

 

 

0
tgyoga
4/21/2009 12:19:56 PM
poojakulkarni:

DropdownList1.DataValueField = "ST_ID_NMBR" + "^" +"STATUS";

Hi,

i need to have 2 values for the datavaluefield of a dropdownlist.

hence i tried teh above statement,but it didnt work.

Can anybody please tell me how to do it.

Thanks

 

Hi see this article:

http://geekswithblogs.net/dotNETvinz/archive/2009/03/11/displaying-two-column-fields-in-dropdownlist-control.aspx

hope it helps!!!

 


Thanks and Regards
Avinash

avicool08@gmail.com
0
avicool08
4/21/2009 12:22:58 PM

poojakulkarni:
i need to have 2 values for the datavaluefield of a dropdownlist.
 

This should help you to get started..

Displaying Two Column Fields in the DropDownList Control


Regards,Vinz

"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
0
vinz
4/21/2009 12:24:06 PM
Reply:

Web resources about - dropdown list with 2 data value fields - asp.net.getting-started

How to convert unordered list into nicely styled <select> dropdown using jquery?
$('ul.selectdropdown').each(function(){ var select=$(document.createElement('select').insertBefore($(this).hide(); $('>li a', this).each(function(){ ...

Credit Suisse Reiterates On Enbridge Energy Partners, L.P. Following Alberta Dropdown
In a report published Thursday, Credit Suisse analyst John Edwards reiterated an Outperform rating on Enbridge Energy Partners, L.P. (NYSE: EEP), ...

Convert a Menu to a Dropdown for Small Screens
Create a menu that, on smaller screens, changes into a dropdown menu. A dropdown takes up much less screen real estate and can be easier to use. ...

Office-Add-in-Fabric-UI-Sample/Dropdown-demos.html at master · OfficeDev/Office-Add-in-Fabric-UI-Sample ...
Contribute to Office-Add-in-Fabric-UI-Sample development by creating an account on GitHub.

Google Adds Dropdown Menu to Search Results, Hides Cached Pages Inside
Google recently updated their search results format, again moving the link for cached page access somewhere else. Now it hides in a convenient ...

50+ Awesome jQuery Dropdown Menu Tutorials
When designing graphical user interfaces, many people prefer to use a dropdown menu as a GUI element. This allows the user to choose a value ...

Sign out command in dropdown
We can save some space in the menus by putting the Sign-out command in the dropdown menu. As we're building the menu, if I see a command called ...

Google toys with removing Instant Preview in Search, adds dropdown menu with Cached, Similar, Share options ...
Google has added a new drop-down menu to its search results page beside every URL with three options: Cached, Similar, and Share. At the same ...

Facebook Fan Page Changes You Haven’t Heard About
... fashion appears at the top center of the page if you scroll down to the cover image or any point lower. A box labeled highlights has a dropdown ...

Edit Companies - Eric Feng - CrunchBase Person Profile
If this person is an investor, please only submit companies for which he/she has a functional role (like Board, Advisor, etc). Click 'Past?' ...

Resources last updated: 11/22/2015 6:31:02 AM