Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now