Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
570
Simple WebCombo Control Population
posted

I am missing something pretty basic somewhere.

I am attempting to populate controls on my .aspx from values in my business object. the controls consist of one WebNumericEdit, one WebTextEdit, and one WebCombo.

On page load, I set the WebCombo.DataSourceID = Nothing just to fire the InitializeDataSource. In the InitializeDataSource, I retrieve a dataset of data, set the datasource and databind to the combo. The combo loads the items fine.

Then I retrieve my business object (LicenseClass) and I am trying to populate the controls. The numeric edit and text edits populate just fine but I cannot figure out how to set the value of the WebCombo to the value in my object. I am trying to give the user an opportunity to edit an existing record by selecting a different item in the combo.

 Can someone tell me how to set the initial value of the web combo to the value in my business object?

 ...Portion of Page_Load

 

'Trigger the loading of the combo.

licensetypeWebCombo.DataSourceID = Nothing

'Instantiate a license class object and populate the key value.

Dim MyLicenseClass As New LicenseWS.clsLicenseClass

MyLicenseClass.LicenseClassCode = Request.Params("Class")

'Ask the presentation layer to retrieve the class from the business layer.

MyPres.GetNIPRLicenseClass(MyLicenseClass)

'Populate the controls

classcodeWebNumericEdit.Text = MyLicenseClass.LicenseClassCode

nameWebTextEdit.Text = MyLicenseClass.LicenseClass

(the following two lines are just flailing attempts to set the value not meant in reality to have both in place) 

licensetypeWebCombo.SelectedRow = licensetypeWebCombo.Rows.FromKey(MyLicenseClass.LicenseClassCode)

licensetypeWebCombo.DisplayValue = licensetypeWebCombo.FindByValue(MyLicenseClass.LicenseTypeCode).ToString

 ...WebCombo_InitializeDataSource

'Load the combobox

'Instantiate the presentation layer

Dim MyPres As New clsPresentationLogic

'Ask the presentation layer for the list of license types

MyPres.GetLicenseTypes(dsLicenseTypes)

'Set the combo datasource to the dataset

licensetypeWebCombo.DataSource = dsLicenseTypes

licensetypeWebCombo.DataBind()

licensetypeWebCombo.DataTextField = "LicenseType"

licensetypeWebCombo.DataValueField = "LicenseTypeCode"

'Clean up

MyPres = Nothing