Solved

Programmatically Create GridView

Posted on 2008-06-20
4
1,670 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
 
LVL 14

Expert Comment

by:raja_ind82
ID: 21841108
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

734 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