Solved

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

Posted on 2014-02-05
2
1,521 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:murbro
[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 12

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:murbro
ID: 39838156
Thanks very much
0

Featured Post

Technology Partners: 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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

739 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