Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Mapping ID in dropdown

Hi all!

Using PDK.NET 2.0 and MS VS2003.

I am returning two fields from a SQL-select, ID and Name.

In a dropdown I want just the name to show, not the ID. But I still want the name to be connected to the correct ID in my database.

Is this possible?

Regards,

Simon

PS: this is urgent!

replied

Simon,

You would do this the same way you would in a regular ASP.NET Web Form.

I would recommend you not use the SAP Netweaver DropDownByKey, but use the standard ASP.NET DropdownList control for the sake of simplicity. Be sure and apply the same styles to the control though as aesthetic consistency is important in the Portal. You can then learn the DropDownByKey control later (since you say this is urgent).

Here is an example:

IDataReader dr = //Your reader goes here.

while (dr.Read())
{
	ListItem newListItem =  new ListItem();
//This would be the description field in your SQL query. 
	newListItem.Text = dr.GetString(1);
//This would be the value field in your SQL query.
	newListItem.Value = dr.GetString(0); 
	myDdl.Items.Add(newListItem); 
}
myDdl.Items.Add(newList);
myDdl.SelectedIndex = myDdl.Items.Count-1;

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question