Solved

ASP.net VB.net Add GridView dynamically to Table cell

Posted on 2014-02-05
2
1,553 Views
Last Modified: 2014-02-05
Hi. I added the following markup  to my ASP.net web form. How do I name this table and then
add a GridView dynamically to one of it's cells

<table>
<tr>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
</tr>
</table>
0
Comment
Question by:Murray Brown
[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
2 Comments
 
LVL 13

Accepted Solution

by:
Jitendra Patil earned 500 total points
ID: 39838143
you can use  the below code
.aspx code
<asp:Table ID="table1" runat="server" GridLines="Both">
          <asp:TableRow>
             <asp:TableCell ID="TableCell1" runat="server">
             </asp:TableCell>
             <asp:TableCell ID="TableCell2" runat="server">
             </asp:TableCell>
          </asp:TableRow>
          <asp:TableRow>
          <asp:TableCell ID="TableCell3" runat="server">
             </asp:TableCell>
             <asp:TableCell ID="TableCell4" runat="server">
             </asp:TableCell>
          </asp:TableRow>
       </asp:Table>
vb.net code
using System.Collections;
Protected Sub Page_Load(sender As Object, e As EventArgs)
      If Not Page.IsPostBack Then
            TableCell1.Text = "i am first cell"
            TableCell2.Text = "i am second cell"
            TableCell3.Text = " i am third cell"
            For i As Integer = 0 To 19
                  Dim gv As New GridView()
                  gv.ID = "_gridview" & i
                  Dim q As New Queue()
                  q.Enqueue(i)
                  gv.DataSource = q
                  gv.DataBind()
                  TableCell4.Controls.Add(gv)
            Next
      End If
End Sub

in the above code Queue is used for filling data in gridview.

using the asp.net table control you can get each row,column, cells etc in code behind and that can be useful to you.

hope this helps.
0
 

Author Closing Comment

by:Murray Brown
ID: 39838156
Thanks very much
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

634 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