Solved

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

Posted on 2014-02-05
2
1,490 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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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 …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

820 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