The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Design time DropDownList databind?

Last post 07-25-2008, 5:55 AM by rotep. 3 replies.
Sort Posts: Previous Next
  •  07-24-2008, 2:24 AM 10365

    Design time DropDownList databind?

    I'm trying to perform a databind on a dropdownlist using the esDataSource.

    I have a page with 2 esDataSources, one for a gridview, the other one for a dropdownlist. Both datasources connect to the same ES Entity Collection. The gridview shows all records. I now want to use the dropdownlist to create a filter.

    The datasource for the dropdownlist has only ONE column named InspectionType. This is a 2 char field which I want to use as a display- and datamember.

     

    I can add the datasource, select the column, choose the datasource for the dropdownlist, set the datamember, displaymember. But the dropdownlist is not populated...

    Anyone? Or isn't the esDataSource not designed to be used like this and am I taking a wrong approach?

  •  07-25-2008, 2:54 AM 10376 in reply to 10365

    Re: Design time DropDownList databind?

    I was a bit confused by my other question regarding esDataSource where I should let the datasource (or gridview) fill the collection in the esSelect event.

    I now have the dropdownlist working in the following way, is this still correct?

    Code:
    Protected Sub esdsInspectionType_esSelect(ByVal sender As Object, ByVal e As EntitySpaces.Web.esDataSourceSelectEventArgs) Handles esdsInspectionType.esSelect
    
            Dim collQ As New BLL.IntranetApuInspectionQuery
            Dim coll As New ESDS_Test.BLL.IntranetApuInspectionCollection
    
            collQ.Select(collQ.InspectionType.Distinct)
            collQ.es.Distinct = True
            coll.Load(collQ)
            e.Collection = coll
        End Sub
  •  07-25-2008, 4:44 AM 10377 in reply to 10365

    Re: Design time DropDownList databind?

    Good morning, 

    Another approach is:

    Code:
    Code:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not Page.IsPostBack 
    
    ...
    
    
    Code:
    dim f as new FieldCollection
    f.LoadAll() Me.ddlField.DataSource = f Me.ddlField.DataValueField = FieldMetadata.ColumnNames.FieldID Me.ddlField.DataTextField = FieldMetadata.ColumnNames.UserDescription Me.ddlField.DataBind() ... end if end sub

    With this you don't need the second esdatasource unless used for other reasons.
    I believe you need the databind statement at the end to get the ddl to populate.

    Hope this helps

    Gary

  •  07-25-2008, 5:55 AM 10378 in reply to 10377

    Re: Design time DropDownList databind?

    Good afternoon here :-),

    thank you for your suggestion. This is actually the way I was doing it, however I would like to do as much as possible in design-time. So I think the correct approach would be using an esDataSource.

    I do agree that the implementation of the esSelect event uses the same amount of code in the end, so I was hoping that I was doing something wrong...

View as RSS news feed in XML