Using custom DataSet

2 posts, 0 answers
  1. Pierre
    Pierre avatar
    212 posts
    Member since:
    Apr 2007

    Posted 17 Dec 2007 Link to this post

    Hi, I use your ragGridControl for the first time. I need to display a list of ActiveDirectory Groups in the grid. I create a custom Dataset with 2 colums (Img and Nom) and put the groups in it.

    I set the Grid AutoGenerateColum to false and create 2 colum. When I set the datasource to my custom Dataset, I receive a error telling me that the Colum "nom" are alerady in the table...

    Here is my code (sorry for the code directly in the post, but for a unkown reason I can't found the "add code" button in your post toolbar.

    Dim Srch As New DirectorySearcher

    Dim srchResultat As SearchResultCollection

    Dim Resultat As SearchResult

     

    'AJoute les colones

    RadGridGroupes.MasterGridViewTemplate.AutoGenerateColumns =

    False

    Dim imgCol As New GridViewImageColumn

    imgCol.UniqueName =

    "Img"

    imgCol.HeaderText =

    ""

    imgCol.DataField =

    "Img"

    RadGridGroupes.MasterGridViewTemplate.Columns.Add(imgCol)

    Dim txtCol As New GridViewTextBoxColumn

    imgCol.UniqueName =

    "Nom"

    imgCol.DataField =

    "Nom"

    imgCol.Width = 200

    imgCol.HeaderText =

    "Nom"

    RadGridGroupes.MasterGridViewTemplate.Columns.Add(imgCol)

     

     

    Srch.Filter =

    "(&(objectCategory=group))"

    srchResultat = Srch.FindAll

     

    Dim dtTable As New DataTable

    Dim dtRow As DataRow

    dtTable.Columns.Add(

    New DataColumn("Img", System.Type.GetType("System.String")))

    dtTable.Columns.Add(

    New DataColumn("Nom", System.Type.GetType("System.String")))

    dtTable.TableName =

    "Groupes"

    For Each Resultat In srchResultat

    dtRow = dtTable.NewRow

    dtRow.Item(

    "Nom") = Resultat.Properties("name")(0)

    dtTable.Rows.Add(dtRow)

    Next

    RadGridGroupes.DataSource = dtTable

    End Sub

  2. Julian Benkov
    Admin
    Julian Benkov avatar
    1135 posts

    Posted 18 Dec 2007 Link to this post

    Hi Pierre,

    Thank you for writing.

    In your code you are trying to add the image column twice. The wrong line is the following:

    RadGridGroupes.MasterGridViewTemplate.Columns.Add(imgCol)

    You should change it to:

    RadGridGroupes.MasterGridViewTemplate.Columns.Add(txtCol )

    For creating a second text column, please use this code snippet:

    Dim Srch As New DirectorySearcher

    Dim srchResultat As SearchResultCollection

    Dim Resultat As SearchResult

     

    'AJoute les colones

    RadGridGroupes.MasterGridViewTemplate.AutoGenerateColumns =

    False

    Dim imgCol As New GridViewImageColumn("Img")

    imgCol.UniqueName =

    "Img"

    imgCol.HeaderText =

    ""

    RadGridGroupes.MasterGridViewTemplate.Columns.Add(imgCol)

    Dim txtCol As New GridViewTextBoxColumn("Nom")

    imgCol.UniqueName =

    "Nom"

    imgCol.Width = 200

    imgCol.HeaderText =

    "Nom"

    RadGridGroupes.MasterGridViewTemplate.Columns.Add(txtCol )

    Srch.Filter =

    "(&(objectCategory=group))"

    srchResultat = Srch.FindAll

     

    Dim dtTable As New DataTable

    Dim dtRow As DataRow

    dtTable.Columns.Add(

    New DataColumn("Img", System.Type.GetType("System.String")))

    dtTable.Columns.Add(

    New DataColumn("Nom", System.Type.GetType("System.String")))

    dtTable.TableName =

    "Groupes"

    For Each Resultat In srchResultat

    dtRow = dtTable.NewRow

    dtRow.Item(

    "Nom") = Resultat.Properties("name")(0)

    dtTable.Rows.Add(dtRow)

    Next

    RadGridGroupes.DataSource = dtTable

    End Sub


    Contact us again if you have any further questions.

    Best wishes,
    Julian Benkov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top