Solved

Programmatically Create GridView

Posted on 2008-06-20
4
1,671 Views
Last Modified: 2013-11-07
Hi all,

I'm trying to create a GridView for each row in a DataTable and add another DataTable's rows to it. There will be 1 GridView per parent DataTable. I have debugged and stepped through and can see the DataTable has rows, but the EmptyDataText is showing each time.

Can you see what is wrong?
Protected Sub getForums()
        Dim objFr As New groups()
        Dim dt As DataTable = objFr.getGroups()
 
        For Each groupRow As DataRow In dt.Rows
            Dim gvwGroups As New GridView
 
            gvwGroups.AutoGenerateColumns = False
            gvwGroups.EmptyDataText = "There are no groups"
 
            gvwGroups.Caption = groupRow("groupName").ToString
 
            Dim dtForums As DataTable = getParentForumsForGroup(Convert.ToInt32(groupRow("groupID")))
 
            For Each forumRow As DataRow In dtForums.Rows
                Dim field As New BoundField
                field.DataField = forumRow("forumName")
                field.HeaderText = "Forum"
                gvwGroups.Columns.Add(field)
            Next
 
            gvwGroups.DataBind()
            pnlForums.Controls.Add(gvwGroups)
        Next
    End Sub
 
    Private Function getParentForumsForGroup(ByVal groupID As Integer) As DataTable
        Dim objFr As New forums()
        Dim dt As DataTable = objFr.getParentForumsByGroupID(groupID)
 
        Return dt
    End Function

Open in new window

0
Comment
Question by:G0ggy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 33

Accepted Solution

by:
raterus earned 500 total points
ID: 21831951
You are never setting,

gvwGroups.DataSource = (...)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question