According to your description, I have made a sample here.It will be very simpleto accomplish your requirement by using .clone() in Jquery . Here is the demo , I hope it could help you.
Public Class Gridview
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load // bind Gridview1 and bind Gridview2
Dim sql1 = "select * from db"
GridView1.DataSource = SqlHelper.ExecuteDataTable(sql1)
GridView1.DataBind()
Dim sql2 = "select * from test"
GridView2.DataSource = SqlHelper.ExecuteDataTable(sql2)
GridView2.DataBind()
End Sub
End Class
For the 2 grid views ,I have Insert button with few text box under the grid view so that upon click insert statement will work. Which will insert the values in to the database. One Add panel button is also there for clone purpose
These 2 grid views will be empty at first showing only the header.User will insert the values from the textboxes placed below gridview and click Insert button.then user will click Add panel.
If add panel is clicked, a new panel with 2 empty gridviews must show just with the header, so that user can insert values in to the table.(using textbox). is this possible
values can not be cloned. Now once I click insert button again for the second clone ,first panel is only visible and all other is disappearing.
Will using repeater solve the issue, if so please explain.Appreciate the help.
Member
185 Points
401 Posts
Repeating Panel with Gridview in vb.net
Feb 12, 2019 10:01 AM|shsu|LINK
I have a Panel (PanelA) in VB.NET,
This panel is having 2 grid view (which is allowed to edit) with different tables.
Once I click Add Panel button,I want to create new panel(PanelB) with these 2 grid views
like that ,how many times user click Add Panel button,that many times new panel must be created with 2 editable gridviews.
Is this possible in vb.net.How to show new panel with 2 gridviews on each button click?. Appreciate the help
All-Star
53091 Points
23659 Posts
Re: Repeating Panel with Gridview in vb.net
Feb 12, 2019 03:34 PM|mgebhard|LINK
Sure, the common Web Forms Approach is using a DataBound control. A Repeater should work great.
Participant
1300 Points
522 Posts
Re: Repeating Panel with Gridview in vb.net
Feb 13, 2019 03:06 AM|Wei Zhang|LINK
Hi shsu,
According to your description, I have made a sample here.It will be very simpleto accomplish your requirement by using .clone() in Jquery . Here is the demo , I hope it could help you.
aspx:
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="../Scripts/jquery-3.3.1.js"></script> <script> $(function () { $("#Button1").click(function () { $("#Panel1").clone().appendTo("#form1") //clone the content of panel }) }) </script> </head> <body> <form id="form1" runat="server"> <div> <input id="Button1" type="button" value="add panel" /> <asp:Panel ID="Panel1" runat="server"> <asp:GridView ID="GridView1" runat="server" AutoGenerateEditButton="true"></asp:GridView> <asp:GridView ID="GridView2" runat="server" AutoGenerateEditButton="true"></asp:GridView> </asp:Panel> </div> </form> </body> </html>
aspx.cs
It shows as below:
Best Regards
Wei Zhang
Member
185 Points
401 Posts
Re: Repeating Panel with Gridview in vb.net
Feb 14, 2019 06:01 AM|shsu|LINK
Thanks Mgebhard and Wei Zhang
Some issues I am facing in the Clone,is that:
For the 2 grid views ,I have Insert button with few text box under the grid view so that upon click insert statement will work. Which will insert the values in to the database. One Add panel button is also there for clone purpose
These 2 grid views will be empty at first showing only the header.User will insert the values from the textboxes placed below gridview and click Insert button.then user will click Add panel.
If add panel is clicked, a new panel with 2 empty gridviews must show just with the header, so that user can insert values in to the table.(using textbox). is this possible
values can not be cloned. Now once I click insert button again for the second clone ,first panel is only visible and all other is disappearing.
Will using repeater solve the issue, if so please explain.Appreciate the help.