ASP.NET Adding item to repeater is messing up the layout of my page with tabs
I am trying to make a web form that has several dynamic tabs at the top.
Under the second tab, there is an "add new" button which can add items to the list using a repeater
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><%@ Register Assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxControlToolkit" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<div class="container">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#Menu1">Menu1</a></li>
<li><a data-toggle="tab" href="#Menu2">Menu2</a></li>
<li><a data-toggle="tab" href="#Menu3">Menu3</a></li>
</ul>
<div class="tab-content">
<div id="Menu1" class="tab-pane fade in active">
<h3>Menu1</h3>
<p>Content of Menu1 </p>
</div>
<div id="Menu2" class="tab-pane fade">
<h3>Menu2</h3>
<p>
<asp:Button Text="Add New" ID="btnAdd1" OnClick="btnAdd_Click1" runat="server" />
<asp:Repeater runat="server" ID="Repeater1">
<HeaderTemplate>
<div class="container">
<table class="table">
<thead>
<tr>
<th>Parameter One</th>
<th>Parameter Two</th>
<th>Parameter Three</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Textbox runat="server" Width="100px" ID="txtParameterOne" Text='<%# Eval("ParameterOne") %>' />
</td>
<td>
<asp:Textbox runat="server" Width="100px" ID="txtParameterTwo" Text='<%# Eval("ParameterTwo") %>' />
</td>
<td>
<asp:Textbox runat="server" Width="100px" ID="txtParameterThree" Text='<%# Eval("ParameterThree") %>' />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</p>
</div>
<div id="Menu3" class="tab-pane fade">
<h3>Menu3</h3>
<p>This content is supposed to be under "Menu3" Tab.</p>
</div>
</div>
</div>
</asp:Content>
The code behind for "add new" button
public void btnAdd_Click1(object sender, EventArgs e)
{
List<FirData> dataList = new List<FirData>();
//-- add all existing values to a list
foreach (RepeaterItem item in Repeater1.Items)
{
dataList.Add(
new FirData()
{
ParameterOne = (item.FindControl("txtParameterOne") as System.Web.UI.WebControls.TextBox).Text,
ParameterTwo = (item.FindControl("txtParameterTwo") as System.Web.UI.WebControls.TextBox).Text,
ParameterThree = (item.FindControl("txtParameterThree") as System.Web.UI.WebControls.TextBox).Text,
});
}
//-- add a blank row to list to show a new row added
dataList.Add(new FirData());
Repeater1.DataSource = dataList;
Repeater1.DataBind();
}
Things works fine without adding any item to the repeater. But once items were added, content under dynamic tabs start to overlap with each other. Please check out the first picture attached below.
This is what would happen after items being added to the page under "Menu2" tab. The part in the red circle is supposed to be showing under the "Menu3" tab instead. Link to the screenshot
If I reload the page and do not click the add new button under the "Menu2" Tab. (Meaning that there is no item under the "Menu2" tab.) Everything would work as expected. The content in the read circle in the previous picture is under the "Menu3" tab now. (which is how it supposed to be)Link to the Screenshot
Thank you!
c# asp.net tabs repeater
add a comment |
I am trying to make a web form that has several dynamic tabs at the top.
Under the second tab, there is an "add new" button which can add items to the list using a repeater
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><%@ Register Assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxControlToolkit" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<div class="container">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#Menu1">Menu1</a></li>
<li><a data-toggle="tab" href="#Menu2">Menu2</a></li>
<li><a data-toggle="tab" href="#Menu3">Menu3</a></li>
</ul>
<div class="tab-content">
<div id="Menu1" class="tab-pane fade in active">
<h3>Menu1</h3>
<p>Content of Menu1 </p>
</div>
<div id="Menu2" class="tab-pane fade">
<h3>Menu2</h3>
<p>
<asp:Button Text="Add New" ID="btnAdd1" OnClick="btnAdd_Click1" runat="server" />
<asp:Repeater runat="server" ID="Repeater1">
<HeaderTemplate>
<div class="container">
<table class="table">
<thead>
<tr>
<th>Parameter One</th>
<th>Parameter Two</th>
<th>Parameter Three</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Textbox runat="server" Width="100px" ID="txtParameterOne" Text='<%# Eval("ParameterOne") %>' />
</td>
<td>
<asp:Textbox runat="server" Width="100px" ID="txtParameterTwo" Text='<%# Eval("ParameterTwo") %>' />
</td>
<td>
<asp:Textbox runat="server" Width="100px" ID="txtParameterThree" Text='<%# Eval("ParameterThree") %>' />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</p>
</div>
<div id="Menu3" class="tab-pane fade">
<h3>Menu3</h3>
<p>This content is supposed to be under "Menu3" Tab.</p>
</div>
</div>
</div>
</asp:Content>
The code behind for "add new" button
public void btnAdd_Click1(object sender, EventArgs e)
{
List<FirData> dataList = new List<FirData>();
//-- add all existing values to a list
foreach (RepeaterItem item in Repeater1.Items)
{
dataList.Add(
new FirData()
{
ParameterOne = (item.FindControl("txtParameterOne") as System.Web.UI.WebControls.TextBox).Text,
ParameterTwo = (item.FindControl("txtParameterTwo") as System.Web.UI.WebControls.TextBox).Text,
ParameterThree = (item.FindControl("txtParameterThree") as System.Web.UI.WebControls.TextBox).Text,
});
}
//-- add a blank row to list to show a new row added
dataList.Add(new FirData());
Repeater1.DataSource = dataList;
Repeater1.DataBind();
}
Things works fine without adding any item to the repeater. But once items were added, content under dynamic tabs start to overlap with each other. Please check out the first picture attached below.
This is what would happen after items being added to the page under "Menu2" tab. The part in the red circle is supposed to be showing under the "Menu3" tab instead. Link to the screenshot
If I reload the page and do not click the add new button under the "Menu2" Tab. (Meaning that there is no item under the "Menu2" tab.) Everything would work as expected. The content in the read circle in the previous picture is under the "Menu3" tab now. (which is how it supposed to be)Link to the Screenshot
Thank you!
c# asp.net tabs repeater
add a comment |
I am trying to make a web form that has several dynamic tabs at the top.
Under the second tab, there is an "add new" button which can add items to the list using a repeater
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><%@ Register Assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxControlToolkit" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<div class="container">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#Menu1">Menu1</a></li>
<li><a data-toggle="tab" href="#Menu2">Menu2</a></li>
<li><a data-toggle="tab" href="#Menu3">Menu3</a></li>
</ul>
<div class="tab-content">
<div id="Menu1" class="tab-pane fade in active">
<h3>Menu1</h3>
<p>Content of Menu1 </p>
</div>
<div id="Menu2" class="tab-pane fade">
<h3>Menu2</h3>
<p>
<asp:Button Text="Add New" ID="btnAdd1" OnClick="btnAdd_Click1" runat="server" />
<asp:Repeater runat="server" ID="Repeater1">
<HeaderTemplate>
<div class="container">
<table class="table">
<thead>
<tr>
<th>Parameter One</th>
<th>Parameter Two</th>
<th>Parameter Three</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Textbox runat="server" Width="100px" ID="txtParameterOne" Text='<%# Eval("ParameterOne") %>' />
</td>
<td>
<asp:Textbox runat="server" Width="100px" ID="txtParameterTwo" Text='<%# Eval("ParameterTwo") %>' />
</td>
<td>
<asp:Textbox runat="server" Width="100px" ID="txtParameterThree" Text='<%# Eval("ParameterThree") %>' />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</p>
</div>
<div id="Menu3" class="tab-pane fade">
<h3>Menu3</h3>
<p>This content is supposed to be under "Menu3" Tab.</p>
</div>
</div>
</div>
</asp:Content>
The code behind for "add new" button
public void btnAdd_Click1(object sender, EventArgs e)
{
List<FirData> dataList = new List<FirData>();
//-- add all existing values to a list
foreach (RepeaterItem item in Repeater1.Items)
{
dataList.Add(
new FirData()
{
ParameterOne = (item.FindControl("txtParameterOne") as System.Web.UI.WebControls.TextBox).Text,
ParameterTwo = (item.FindControl("txtParameterTwo") as System.Web.UI.WebControls.TextBox).Text,
ParameterThree = (item.FindControl("txtParameterThree") as System.Web.UI.WebControls.TextBox).Text,
});
}
//-- add a blank row to list to show a new row added
dataList.Add(new FirData());
Repeater1.DataSource = dataList;
Repeater1.DataBind();
}
Things works fine without adding any item to the repeater. But once items were added, content under dynamic tabs start to overlap with each other. Please check out the first picture attached below.
This is what would happen after items being added to the page under "Menu2" tab. The part in the red circle is supposed to be showing under the "Menu3" tab instead. Link to the screenshot
If I reload the page and do not click the add new button under the "Menu2" Tab. (Meaning that there is no item under the "Menu2" tab.) Everything would work as expected. The content in the read circle in the previous picture is under the "Menu3" tab now. (which is how it supposed to be)Link to the Screenshot
Thank you!
c# asp.net tabs repeater
I am trying to make a web form that has several dynamic tabs at the top.
Under the second tab, there is an "add new" button which can add items to the list using a repeater
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><%@ Register Assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxControlToolkit" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<div class="container">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#Menu1">Menu1</a></li>
<li><a data-toggle="tab" href="#Menu2">Menu2</a></li>
<li><a data-toggle="tab" href="#Menu3">Menu3</a></li>
</ul>
<div class="tab-content">
<div id="Menu1" class="tab-pane fade in active">
<h3>Menu1</h3>
<p>Content of Menu1 </p>
</div>
<div id="Menu2" class="tab-pane fade">
<h3>Menu2</h3>
<p>
<asp:Button Text="Add New" ID="btnAdd1" OnClick="btnAdd_Click1" runat="server" />
<asp:Repeater runat="server" ID="Repeater1">
<HeaderTemplate>
<div class="container">
<table class="table">
<thead>
<tr>
<th>Parameter One</th>
<th>Parameter Two</th>
<th>Parameter Three</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Textbox runat="server" Width="100px" ID="txtParameterOne" Text='<%# Eval("ParameterOne") %>' />
</td>
<td>
<asp:Textbox runat="server" Width="100px" ID="txtParameterTwo" Text='<%# Eval("ParameterTwo") %>' />
</td>
<td>
<asp:Textbox runat="server" Width="100px" ID="txtParameterThree" Text='<%# Eval("ParameterThree") %>' />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</p>
</div>
<div id="Menu3" class="tab-pane fade">
<h3>Menu3</h3>
<p>This content is supposed to be under "Menu3" Tab.</p>
</div>
</div>
</div>
</asp:Content>
The code behind for "add new" button
public void btnAdd_Click1(object sender, EventArgs e)
{
List<FirData> dataList = new List<FirData>();
//-- add all existing values to a list
foreach (RepeaterItem item in Repeater1.Items)
{
dataList.Add(
new FirData()
{
ParameterOne = (item.FindControl("txtParameterOne") as System.Web.UI.WebControls.TextBox).Text,
ParameterTwo = (item.FindControl("txtParameterTwo") as System.Web.UI.WebControls.TextBox).Text,
ParameterThree = (item.FindControl("txtParameterThree") as System.Web.UI.WebControls.TextBox).Text,
});
}
//-- add a blank row to list to show a new row added
dataList.Add(new FirData());
Repeater1.DataSource = dataList;
Repeater1.DataBind();
}
Things works fine without adding any item to the repeater. But once items were added, content under dynamic tabs start to overlap with each other. Please check out the first picture attached below.
This is what would happen after items being added to the page under "Menu2" tab. The part in the red circle is supposed to be showing under the "Menu3" tab instead. Link to the screenshot
If I reload the page and do not click the add new button under the "Menu2" Tab. (Meaning that there is no item under the "Menu2" tab.) Everything would work as expected. The content in the read circle in the previous picture is under the "Menu3" tab now. (which is how it supposed to be)Link to the Screenshot
Thank you!
c# asp.net tabs repeater
c# asp.net tabs repeater
asked Nov 20 '18 at 19:59
Greta LiuGreta Liu
52
52
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Below <ItemTemplate>
you need to add <FooterTemplate>
and include the tbody
, table
and container div
closing tags like this:
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</div> <!--container div closing -->
</FooterTemplate>
Thank you very much! This solved my problem. I thought the Footer part was optional before...
– Greta Liu
Nov 20 '18 at 20:52
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400661%2fasp-net-adding-item-to-repeater-is-messing-up-the-layout-of-my-page-with-tabs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Below <ItemTemplate>
you need to add <FooterTemplate>
and include the tbody
, table
and container div
closing tags like this:
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</div> <!--container div closing -->
</FooterTemplate>
Thank you very much! This solved my problem. I thought the Footer part was optional before...
– Greta Liu
Nov 20 '18 at 20:52
add a comment |
Below <ItemTemplate>
you need to add <FooterTemplate>
and include the tbody
, table
and container div
closing tags like this:
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</div> <!--container div closing -->
</FooterTemplate>
Thank you very much! This solved my problem. I thought the Footer part was optional before...
– Greta Liu
Nov 20 '18 at 20:52
add a comment |
Below <ItemTemplate>
you need to add <FooterTemplate>
and include the tbody
, table
and container div
closing tags like this:
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</div> <!--container div closing -->
</FooterTemplate>
Below <ItemTemplate>
you need to add <FooterTemplate>
and include the tbody
, table
and container div
closing tags like this:
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</div> <!--container div closing -->
</FooterTemplate>
answered Nov 20 '18 at 20:38
Mohsin MehmoodMohsin Mehmood
2,3512513
2,3512513
Thank you very much! This solved my problem. I thought the Footer part was optional before...
– Greta Liu
Nov 20 '18 at 20:52
add a comment |
Thank you very much! This solved my problem. I thought the Footer part was optional before...
– Greta Liu
Nov 20 '18 at 20:52
Thank you very much! This solved my problem. I thought the Footer part was optional before...
– Greta Liu
Nov 20 '18 at 20:52
Thank you very much! This solved my problem. I thought the Footer part was optional before...
– Greta Liu
Nov 20 '18 at 20:52
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400661%2fasp-net-adding-item-to-repeater-is-messing-up-the-layout-of-my-page-with-tabs%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown