Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 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

27 Experts available now in Live!

Get 1:1 Help Now