on 04-18-2006 10:29 AM
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!
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;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks to your help i managed to connect with sap dropdown control:
sqlConnection1.Open();
IDataReader dr = this.sqlSelectCommand2.ExecuteReader();
while (dr.Read())
{
SAP.Web.UI.Controls.DropDownListItem newListItem = new SAP.Web.UI.Controls.DropDownListItem();
//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.Key = dr.GetInt32(0).ToString();
DropDownByKey1.Items.Add(newListItem);
}
sqlConnection1.Close();
Printed the code in case anyone else needs it.
Simon
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.