cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with the DropDownByKey Control

Former Member
0 Kudos

Hi Dear,

I have got a problem viewing the Items of a filled DropDownByKey Control.

I want to fill the Control dynamically by setting the .DataSource Property. The type of the DataSource is a DataView.

The following lines

....

....

dv=mySpecialDataView();

ddbkObject.DataSource=dv;

ddbkObject.DataBind();

....

do fill the Control, but no item in the Control is displayed. Whether the control is filled up or not, i do check with debugging. The .Rows.Count property of the DataSource gives me the right result.

Do I miss some properties to be set?

On the other Hand i have got a ASP.NET DropDownList Control, which is assigned the same DataSource. The ASP.NET Control shows me all the items filled into the DropDownList.

Where is the problem?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ofer,

thanks for your reply.

I do know the documents. But I am missing some sample code. Do you can help me out?

Former Member
0 Kudos

Hi again,

Ok, here you go (this assumes myDataSource has "key" and "text" columns):


private void Page_Load(object sender, System.EventArgs e)
{
 DropDownByKey1.DataSource = myDataSource;
 DropDownByKey1.DataBind();
}

// Add handler to the ItemCreated event of the 
//DropDownByKey and bind the data to the field

private void DropDownByKey1_ItemCreated(object sender, SAP.Web.UI.Controls.AbstractDropDown.ItemEventArgs e)
{
 // Binding the data to the fields
 e.Item.Key = DataBinder.GetPropertyValue(e.Item.DataSourceRow.DataItem, "key", null);
 e.Item.Text = DataBinder.GetPropertyValue(e.Item.DataSourceRow.DataItem, "text", null);
}

Regards,

Ofer

-


Have you filled the PDK survey yet? You can win an MP3 player!!!

http://feedback.sap.com/efs/vote?campaign=39c7899ecca40a6709a638bd0388ac8b&org=332

Former Member
0 Kudos

Thanks Ofer,

but there is still s.th. missing and I do not know what. The DropDownByKey still does not display the values.

Former Member
0 Kudos

There was nothing missing. There was s.th. too much

I had assigned a value to the ItemTemplate Value. Deleting this Values made it work.

Thank you very much

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

If you want to understand more about the NetWeaver control (and why what you did doesn't work) I recommend you first read https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/sap netweaver .net controls vs. asp.net controls.pdf

In your case you should concentrate at the "Complex DataBinding" Section.... but you can read it all.

Reading this you will learn that the Netweaver controls were "meant" to be bound in design time (in the sense that it's the easiest and most powerful way to do it). But since this isn't your case, the solution is to use the "ItemDataBound" Event to explicitly say which property binds to which... (since the ItemTemplate isn't bound).

See https://media.sdn.sap.com/html/submitted_docs/dotnet/Reference/SAP.Web.UI.Controls.AbstractDropDown....

Hope that helped,

Ofer