Hi,

In my page I have a GridView and I'm binding it in the code behind.
The data in my gridView should appear similar to a directory structure
(but in my case using a TreeView doesn't apply). So my GridView should
be like this:

Name 1
    Name 1.1
    Name 1.2
Name 2
    Name 2.1
        Name 2.1.1

To do this, I'm updating the value for the column "Name" in the
DataTable used to populate the GridView. For example, for Name 1.1,
I'm doing:
newName = "    " + row("Name")
row("Name") = newName

The DataTable is with the values I expect, but the values in the
GridView are not matching the values in the DataTable. In the GridView
the list is just:

Name 1
Name 1.1
Name 1.2
Name 2
Name 2.1
Name 2.1.1

My code is as follows:
GridView:

<asp:GridView ...>
        <Columns>
            <asp:TemplateField HeaderText="Title">
                <ItemTemplate>
                    <%#Eval("Name")%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:ButtonField Text="Details..." HeaderText="Show
Details" CommandName="Select">
            </asp:ButtonField>
        </Columns>
    </asp:GridView>


Code for binding the DataTable:

Private Function BindmyGridView () As DataTable
        Dim DatabaseConnection As New SqlConnection
(ConfigurationManager.ConnectionStrings("myServer").ConnectionString)
        Dim selectSQL As String = "SELECT [ID], [Name] FROM [Table]"
        Dim selectCMD As New SqlCommand(selectSQL, DatabaseConnection)
        Dim dTable As New DataTable()
        Dim adapter As New SqlDataAdapter()
        dTable.Columns.Add("Id")
        dTable.Columns.Add("Name")

        adapter.SelectCommand = selectCMD
        adapter.Fill(dTable)

        dTable = indentTable(dTable)

        myGridView.DataSource = dTable
        myGridView.DataBind()

        Return dTable
    End Function


Any ideas of what's is wrong and what do to to fix it?

Thanks in advance for all the replies,

Ana

Reply via email to