I create table inside a repeater
and the data appears correctly, it will be two records looks like in the image below.
what i want: how to make accordion when user clicks on the deposit number(Example 16), new table will appear and contain data.
this is the repeater the first repeater code:
<asp:Repeater ID="rptDep" runat="server" >
<HeaderTemplate>
<table class="table table-hover table-striped table-condensed table-bordered table-responsive">
<tr>
<th>Deposit No.</th>
<th>Custom Declaration No.</th>
<th>Category</th>
<th>Location</th>
<th>Goods Description</th>
<th>Units Balance</th>
<th>WT Balance</th>
<th>Goods Balance Amount(LC)</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td> <%#Eval("depNo") %></td>
<td><%#Eval("customDec") %></td>
<td><%#Eval("category") %></td>
<td><%#Eval("location") %></td>
<td><%#Eval("goodDesc") %></td>
<td><%#Eval("unitsBal") %></td>
<td><%#Eval("wtBal") %></td>
<td><%#Eval("lcBal") %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
I know that it will be a second repeater, but how to implement that, or how to use foreach statement?
I got it, I found the solution by reading this article:
Implement Nested Repeater (Repeater inside Repeater) with example in ASP.Net using C# and VB.Net
Related
I'm trying to use an ASP:DataList to display data from my data source. Everything works ok, except I'm getting ASP to add an extra column when there isn't one. The Header Template and Item Template are shown below
<asp:DataList runat="server" ID="xTable" DataKeyField="PK_PurchaseID" DataSourceID="SqlDataSource1" RepeatLayout="table" CssClass="table">
<HeaderTemplate>
<td>PuchaseID</td>
<td>Last Name</td>
<td>First name</td>
<td>Address1</td>
<td>Email Sent</td>
</HeaderTemplate>
<ItemTemplate>
<td><%# Eval("PK_PurchaseID") %></td>
<td><%# Eval("LastName") %></td>
<td><%# Eval("FirstName") %></td>
<td><%# Eval("Address1") %></td>
<td><%# Eval("[Email Sent]") %></td>
</ItemTemplate>
</asp:DataList>
And is the the DOM object created. I would expect 5 columns in the table yet it is rendered as 6
<table class="table" id="xTable" style="border-collapse: collapse;" cellspacing="0">
<tbody><tr>
<td>
<td>PuchaseID</td>
<td>Last Name</td>
<td>First name</td>
<td>Address1</td>
<td>Email Sent</td>
</tr><tr>
<td>
<td>3</td>
<td>Albdddim</td>
<td>James </td>
<td>1----63rd Ave.</td>
<td>true</td>
</tr>
I can not figure you why an initial column is being created. I changed the CSS, even removed it and still the same result. I have verified the SQL only returns the 5 columns (even if it returned more or less that shouldn't make a difference)
Thanks Chris
The HeaderTemplate and ItemTemplate are meant to be td elements so it automatically creates the td. If you do something like this
<asp:DataList runat="server" ID="xTable" DataKeyField="PK_PurchaseID" DataSourceID="SqlDataSource1" RepeatLayout="table" CssClass="table">
<HeaderTemplate>
PuchaseID
<td>Last Name</td>
<td>First name</td>
<td>Address1</td>
<td>Email Sent</td>
</HeaderTemplate>
<ItemTemplate>
<%# Eval("PK_PurchaseID") %>
<td><%# Eval("LastName") %></td>
<td><%# Eval("FirstName") %></td>
<td><%# Eval("Address1") %></td>
<td><%# Eval("[Email Sent]") %></td>
</ItemTemplate>
</asp:DataList>
It would put the purchase ID in the first td that is created and then fill out the table like you want.
I display the list of table names when a particular database is selected from the drop down list. Number of tables in my database is more than 100. I don't want to display it as a single column and scroll the page. I want to display it as a table. Also each table name is a link to view its corresponding table details. can anyone help me with the technique to achieve it ?
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table border="1">
<tr>
<td colspan="5">
Tables
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<%--<tr>--%>
<td><asp:Label ID="lbl_TableName" runat="server" Text='<%#Eval("table_name")%>' /></td>
<%-- </tr>--%>
</ItemTemplate>
<%-- <SeparatorTemplate>
<td colspan="4"> name</td>
</SeparatorTemplate>--%>
<%-- <AlternatingItemTemplate>
<td> break</td>
</AlternatingItemTemplate>--%>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
I have an <asp:Repeater> control that loads its data from a database.
To specify which column will be used where in the .aspx file, I use inside the Repeater's ItemTempate
<%# DataBinder.Eval(Container.DataItem, "column1")%>
Now when I need to make changes eg. I want another column instead of column1, I have to open Visual Studio, make the changes, publish the project again, and upload it to the server.
How can this control be more adjustable without having to change the source code each time?
Is there any other control that will do what I need better?
ASPX markup:
<table class="uk-table">
<thead>
<tr>
<th>User Name</th>
<th>Date 1</th>
<th>Date 2</th>
<th>State</th>
</tr>
</thead>
<tbody>
<asp:Repeater runat="server" ID="Repeater2">
<HeaderTemplate></HeaderTemplate>
<ItemTemplate>
<tr class="uk-table-middle">
<td><%# DataBinder.Eval(Container.DataItem,"column1")%></span></td>
<td><%# DataBinder.Eval(Container.DataItem,"column2")%></td>
<td><%# DataBinder.Eval(Container.DataItem,"column3")%> </td>
<td><%# DataBinder.Eval(Container.DataItem,"column4")%></span></td>
</tr>
</ItemTemplate>
<FooterTemplate></FooterTemplate>
</asp:Repeater>
</tbody>
</table>
You need to define a condition like the following and save your condition either in the database or an XML file or even in the web.config (on yours) and do the following. Don't forget to retrieve your condition out of the repeater if you wanna apply to all rows:
<%
var myCondition = true; // whatever it could be...
%>
<asp:Repeater runat="server" ID="Repeater2">
<HeaderTemplate></HeaderTemplate>
<ItemTemplate>
<tr class="uk-table-middle">
<% if (mycondition){ %>
<td><%# DataBinder.Eval(Container.DataItem,"column1")%></span></td>
<td><%# DataBinder.Eval(Container.DataItem,"column2")%></td>
<% }else{ %>
<td><%# DataBinder.Eval(Container.DataItem,"column2")%></td>
<td><%# DataBinder.Eval(Container.DataItem,"column1")%></span></td>
<% } %>
<td><%# DataBinder.Eval(Container.DataItem,"column3")%> </td>
<td><%# DataBinder.Eval(Container.DataItem,"column4")%></span></td>
</tr>
</ItemTemplate>
<FooterTemplate></FooterTemplate>
</asp:Repeater
I'm new to ASP.NET techonology and I'm trying to use datatable Jquery with a repeater.
But it doesn't work with the value inside the table. It work with just the head (see below). These data come from a database.
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="Model2">
<HeaderTemplate>
<table id="table_id">
<thead>
<tr>
<th>Nom</th>
<th>ip</th>
<th>askit</th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tbody>
<tr>
<td><%# Eval("Li_Id")%></td>
<td><%# Eval("Li_ip")%> </td>
<td><%# Eval("Li_nom_askit")%> </td>
</tr>
</tbody>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
And here it's what I get
Screen of what I have
So for example the line with id '594' is not in the datable that I have create.
I try to use a ListView but it doesn't work.
Does anybody know why ?
Thanks
You're creating a separate tbody around each row. Move the opening tbody tag to the end of the header template and the closing tbody tag to the beginning of the footer template.
(I'm assuming you're referring to the datatables.net jQuery plugin.)
Basically what i would like to do is have a button which is only created for entries that have been flagged in a separate table for sending. So for example if i edit a record, i flag this other table and would like a send button to appear next to that record via the repeater below - is this possible? Can i do a check by calling a method for example unsure :(
<asp:Repeater ID="DepartmentsList" runat="server">
<HeaderTemplate>
<table id="grouptable" class="table table-bordered table-striped">
<thead>
<tr>
<th>Send</th>
<th>ID</th>
<th>Name</th>
<th>Last Modified</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<input type="checkbox" name="sendSelect[]" value="<%# Eval("Dept_ID") %>"</input></td>
<td><%# Eval("Dept_ID") %></td>
<td><%# Eval("DESC") %> </td>
<td><%# Eval("CHG_DATE") %></td>
<td><a class="btn btn-info" href="<%# Eval("gURL") %>"><i class="icon-pencil icon-white"></i> Edit</a><asp:Button ID="Button1" runat="server" Text="Send" /></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</FooterTemplate>
</asp:Repeater>
You can do a check and inspect the current data record being bound to the repeater by using the DepartmentsList_OnItemDataBound event. It gives you all the power you need to dynamically change what's being bound and created in the repeater's item.