Select to view content in your preferred language

Bind attribute field to drop down list

2866
13
05-20-2010 12:59 AM
NehayaArabeiat
Emerging Contributor
Hi,

How can I bind attribute field to drop down list in .net application.

Thanks alot
0 Kudos
13 Replies
NehayaArabeiat
Emerging Contributor
Hi James,

Thanks for your reply the code works but I have another problem I want towant to concatenate a string with a featureclass name I try  gov = String.Concat(govlist, "_dist") but it displays

"not found table name"
0 Kudos
JamesCrandall
MVP Frequent Contributor
Hi James,

Thanks for your reply the code works but I have another problem I want towant to concatenate a string with a featureclass name I try  gov = String.Concat(govlist, "_dist") but it displays

"not found table name"


You will have to provide the exact code you are trying to implement.  I cannot tell what it is you are attempting from the code snippet you provided.

Do you need to get the String value of the FeatureClass's name?
0 Kudos
NehayaArabeiat
Emerging Contributor
Here is the full code for the function and form load, I want to get the featureclass name and concatenate it with a string:

Public Sub FillDistricts(ByVal pclass As String, ByVal fieldname As String, ByVal pQF As String)

        pWorkSpace = pGDBWSF.OpenFromFile("E:\ArcGis Engine Projects\Data Layers\SDE GDB\sde_gdb.gdb", 0)

        '  pEnumDataset = pWorkSpace.get_datasets(ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTFeatureDataset)
        pEnumDataset = pWorkSpace.Datasets(esriDatasetType.esriDTFeatureDataset)

        ' pEnumDataset = pWorkSpace.Datasets(esriDatasetType.esriDTFeatureDataset)

        'pEnumDataset.Reset()
        pDataset = pEnumDataset.Next

        Dim FCN As String
        FCN = Gov_List.SelectedText

        pFeatureworkspace = pGDBWSF.OpenFromFile("E:\ArcGis Engine Projects\Data Layers\SDE GDB\sde_gdb.gdb", 0)

        Dim pTable As ITable
        Dim pTableSort As ITableSort
        Dim sFieldName As String = fieldname
        Dim pCursor As ICursor

        Dim pFeatureclass As IFeatureClass
        pFeatureclass = pFeatureworkspace.OpenFeatureClass(pclass)

        ' Gets the attribute table from the passed layer
        pTable = pFeatureclass

        ' This example sorts the specificed field name
        pTableSort = New TableSort
        With pTableSort
            .Fields = sFieldName
            .Ascending(sFieldName) = True
            .Table = pTable
        End With

        ' sort the table
        pTableSort.Sort(Nothing)

        ' Loop through sorted records and add to a listbox
        pCursor = pTableSort.Rows
        Dim pQFilter As IQueryFilter
        pQFilter = New QueryFilter
        pQFilter.WhereClause = pQF

        Dim pData As IDataStatistics
        pData = New DataStatistics
        pData.Field = fieldname
        pCursor = pFeatureclass.Search(pQFilter, False)
        'pCursor = pLayer
        pData.Cursor = pCursor
        Dim pEnumVar As System.Collections.IEnumerator
        Dim value As Object

        pEnumVar = pData.UniqueValues
        value = pEnumVar.MoveNext

        For i = 0 To pData.UniqueValueCount - 1
            Dist_List.Items.Add(CStr(pEnumVar.Current)) '<--- this should add the values to your cmbLot Control
            value = pEnumVar.MoveNext
        Next
    End Sub



Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim govlist As String
        govlist = Gov_List.SelectedText
        Dim gov As String = ""
        gov = String.Concat(govlist, "_dist")

        'gov = govlist & "_dist"
      
        FillDistricts(gov, "DIST_NA", "Dist_NE <>' '")

    End Sub
0 Kudos
JamesCrandall
MVP Frequent Contributor
Here is the full code for the function and form load, I want to get the featureclass name and concatenate it with a string:


Use .AliasName of the FeatureClass to access the name.  So in the portion of your code you supplied, just setup a string variable and set it to the .aliasname, which you can then use to concatenate.

Dim pFClassName As String
Dim pFeatureclass As IFeatureClass
pFeatureclass = pFeatureworkspace.OpenFeatureClass(pclass)
pFClassName = pFeatureClass.AliasName



Now you can use pFClassName in your concatenation:

Dim SomeOtherVariableStringValue As String
Dim ConcatenatedStr As String = pFClassName & "_" & SomeOtherVariableStringValue
0 Kudos