do while loop in a table grid

Posted on 2006-06-03
Medium Priority
Last Modified: 2007-12-19
What am I doing wrong here? I'm trying to get the table rows to repeat, but it's not working. Can anyone help?

<%@ Import Namespace="System.Data" %>
<%@ Page Language="VB" %>

<script language="vb" runat="server">

 Sub Page_Load()
     MyGrid.DataSource = CreateData()
  End Sub
  Function CreateData() As ICollection
    Dim dt As New DataTable()
    Dim dr As DataRow
    Dim i as Integer = 1

      dt.Columns.Add(New DataColumn("Display List", GetType(Integer)))
       Do While i <= 5
            'Add a row
            dr = dt.NewRow()            
            dr(0)= i
            i = i + 1

     Dim dv As New DataView(dt)
     Return dv
   End Function

<p>Do While...Loop in a table I hope:</p><br><br>

 <td colspan="3">
                  text="Amortization Table"

<p>This is the do loop not in the table </p>
Dim i as Integer = 1
Do While i <= 5
   <font size="<%=i%>">Welcome to ASP.NET</font><br>
   i = i + 1


Any help will be appreciated.


Question by:nflowers1228
  • 2

Accepted Solution

Sam_Jayander earned 2000 total points
ID: 16823978

The problem is, you have created  a datarow-dr(which belongs to datatable-dt) and also assigned the value. But you have not added it to the datatable.

so insert this line in your do loop.

Do While i <= 5
          'Add a row
          dr = dt.NewRow()            
          dr(0)= i
          dt.Rows.Add(dr)     ----------> new line to be added.
          i = i + 1

Hope this will solve your problem.

LVL 26

Expert Comment

ID: 16826266
why don't u use a datagrid and bind it to ur datasoure?. .. there is no need for all those loops and just requires 2-3 lines of code


Author Comment

ID: 16827025
Thanks Sam_Jayander! that seems to be doing the trick!
LVL 26

Expert Comment

ID: 16840275
am sorry .. should read the question more carefully :-( .. seems like u were indeed using a datagrid and just building a datatable from scrath ..

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

809 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