So, I tried to fill in a ItemRepeater inside a table. But I think there is some kind of error, in the indentation. Code is like this:
<div class="card-body border-bottom bg-white">
<asp:UpdatePanel ID="upFromHome" runat="server">
<ContentTemplate>
<asp:ListView ID="lsHome" runat="server">
<LayoutTemplate>
<div class="col">
<table runat="server" id="tableHome" class="table-bordered table-striped mb-0 table table-responsive">
<thead>
<tr style="text-align: center; font-size: 12px;">
<th scope="col">Employee Id</th>
<th scope="col">Type</th>
<th scope="col">Day</th>
<th scope="col">Month</th>
<th scope="col">Year</th>
<th scope="col">Status</th>
</tr>
</thead>
<tr runat="server" id="itemPlaceholder">
</table>
</LayoutTemplate>
<ItemTemplate> //error is here
<tbody>
<tr runat="server" style="text-align: center; background-color: white; font-size: 11px;">
<th runat="server" style="text-align: center;">
<asp:Label ID="lblUsername" runat="server" Text='<%#Eval("username") %>'></asp:Label></th>
<th runat="server" style="text-align: center;">
<asp:Label ID="lblTipo" runat="server" Text='<%#Eval("tipo") %>' /></th>
<td runat="server" style="text-align: left;">
<asp:Label ID="lblDay" runat="server" Text='<%#Eval("fecha") %>' /></td>
<td runat="server" style="text-align: left;">
<asp:Label ID="lblMes" runat="server" Text='<%#Eval("regHorario") %>' /></td>
<td runat="server" style="text-align: left;">
<asp:Label ID="lblAno" runat="server" Text='<%#Eval("status") %>' /></td>
<td runat="server" style="text-align: center;">
<asp:Button runat="server" ID="status1" class="btn btn-success" Text="Approved" /></td>
</tr>
</tbody>
</ItemTemplate>
</asp:ListView>
</div>
</div>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
But even tho, the code behind in asp works well... I am getting an error in the frontend. This is the error:
System.Web.UI.HtmlControls.HtmlTableCellCollection debe tener elementos de tipo 'System.Web.UI.HtmlControls.HtmlTableCell'. 'ItemTemplate' es de tipo 'System.Web.UI.HtmlControls.HtmlGenericControl'.
Apparently it is misplaced in some div node, but this is the first time I am getting this error.
You started an ItemTemplate without first declaring the table. So:
<ItemTemplate> //error is here
<tbody>
<tr runat="server" style="text-align: center; background-color: white; font-size: 11px;">
the correct thing is to declare the table first:
<ItemTemplate> //error is here
<table>
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
<tr runat="server" style="text-align: center; background-color: white; font-size: 11px;">
</tr>
...
</tbody>
</table>
Related
I'm trying to learn to use listviews instead repeaters all the time with Jquery datatables for more functionality but I'm having a hard time trying to bind it with 0 values in database
Here's my code
<asp:ListView ID="lstArtigos" runat="server" GroupPlaceholderID="groupPlaceHolder1" ItemPlaceholderID="itemPlaceHolder1">
<LayoutTemplate>
<table id="tblArtigos" class="table table-bordered dataTable">
<thead class="thead-dark">
<tr>
<th style="width: 20px;">ID</th>
<th style="width: 120px">Ref. Cliente</th>
<th style="width: 100px">Ref. Interna</th>
<th style="width: 100px">Nome</th>
<th style="width: 100px">Estado</th>
<th style="width: 100px">Logística</th>
<th style="width: 100px">Info Logística</th>
<th style="width: 100px">Data Criação</th>
<th style="width: 10px;">Editar</th>
<th style="width: 10px;">Validar</th>
<th style="width: 10px;">Rejeitar</th>
</tr>
</thead>
<asp:PlaceHolder runat="server" ID="groupPlaceHolder1"></asp:PlaceHolder>
</table>
</LayoutTemplate>
<GroupTemplate>
<tr>
<asp:PlaceHolder runat="server" ID="itemPlaceHolder1"></asp:PlaceHolder>
</tr>
</GroupTemplate>
<ItemTemplate>
<td>
<asp:Label ID="lblIdArtigo" Text="<%# Eval("IdArtigo") %>"></asp:Label></td>
<td>
<asp:Label ID="lblRefCliente" Text="<%# Eval("ReferenciaCliente") %>"></asp:Label></td>
<td>
<asp:Label ID="lblRefInterna" Text="<%# Eval("ReferenciaInterna") %>"></asp:Label></td>
<td>
<asp:Label ID="lblNome" Text="<%# Eval("Nome") %>"></asp:Label></td>
<td>
<asp:Label ID="lblEstado" Text="<%# Eval("EstadoArtigo") %>"></asp:Label></td>
<td>
<asp:Label ID="lblAprovadoLogistica" Text="<%# Eval("AprovadoLogistica") %>"></asp:Label></td>
<td>
<asp:Label ID="lblInformacaoLogistica" Text="<%# Eval("InformacaoLogistica") %>"></asp:Label></td>
<td>
<asp:Label ID="lblDataCriacao" Text="<%# Eval("DataCriacao") %>"></asp:Label></td>
<td class="text-center">
<asp:ImageButton ImageUrl="/Images/Buttons/edit.png" CssClass="" Width="25" runat="server" />
</td>
<td class="text-center">
<asp:ImageButton ImageUrl="/Images/Buttons/success.png" CssClass="" Width="25" runat="server" />
</td>
<td class="text-center">
<asp:ImageButton ImageUrl="/Images/Buttons/x-button.png" CssClass="" Width="25" runat="server" />
</td>
</ItemTemplate>
</asp:ListView>
and in codebehind I bind it with datatable even if it comes empty from database it should appear the jquery message like it does on repeater
private void BindArtigos(int id)
{
lstArtigos.DataSource = Requisicao.GetAll(id);
lstArtigos.DataBind();
}
Also there is no problem with Jquery plugin cause I had a repeater before writing the listview and was working properly
EDIT:
Added the missing columns on table header, still shows nothing and no errors on console
The problem is that you have more cells in the body of the table that in the thead. They must be the same.
<thead class="thead-dark">
<tr>
<th style="width: 20px;">ID</th>
<th style="width: 120px">Ref. Cliente</th>
<th style="width: 100px">Ref. Interna</th>
<th style="width: 100px">Nome</th>
<th style="width: 100px">Logística</th>
<th style="width: 100px">Estado</th>
<th style="width: 10px;">Editar</th>
<th style="width: 10px;">Validar</th>
<th style="width: 10px;">Rejeitar</th>
//add these
<th># 1</th>
<th># 2</th>
</tr>
</thead>
<td>
<asp:Label ID="lblIdArtigo" Text="<%# Eval("IdArtigo") %>"></asp:Label></td>
replace this line with
<td>
<asp:Label ID="lblIdArtigo" Text='<%# Eval("IdArtigo") %>'></asp:Label></td>
and check if it shows data
check out this article
https://www.c-sharpcorner.com/UploadFile/9de7db/listview-control-in-Asp-Net/
I have this repeater asp element:
<asp:Repeater ID="PervousResultsList" runat="server" EnableViewState="False" >
<ItemTemplate>
<div class="row1">
<table style="width: 100%">
<tr>
<td rowspan="4" onclick="parent.parent.ZoomToView(<%# Eval("Lon") %>, <%# Eval("Lat") %>, 2500)" style="cursor: pointer;">
<asp:Image ID="Image1" ImageUrl="~/Images/pushpinred.png" runat="server" Width="32"
Height="32" /></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td rowspan="10">
<asp:Image class="toggleRow" ImageUrl="~/Images/vertical-dots.png" runat="server" Width="32"
Height="32" Style="height: 30px; position: relative; float: left; cursor: pointer;" /></td>
</td>
</tr>
<tr class="pointDescArea">
<td>text:</td>
<td rowspan="2">
<h1 style="color: gray"><%# Eval("Text") %></h1>
</td>
</tr>
<tr class="hidden">
<td>X:</td>
<td><%# Eval("Lon") %></td>
</tr>
<tr class="hidden">
<td>Y:</td>
<td><%# Eval("Lat") %></td>
</tr>
<tr>
</table>
</div>
</ItemTemplate>
<AlternatingItemTemplate>
<div class="row2">
<table style="width: 100%">
<tr>
<td rowspan="4" onclick="parent.parent.ZoomToView(<%# Eval("Lon") %>, <%# Eval("Lat") %>, 2500)" style="cursor: pointer;">
<asp:Image ID="Image1" ImageUrl="~/Images/pushpinred.png" runat="server" Width="32"
Height="32" /></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td rowspan="10">
<asp:Image class="toggleRow" ImageUrl="~/Images/vertical-dots.png" runat="server" Width="32"
Height="32" Style="height: 30px; position: relative; float: left; cursor: pointer;" /></td>
</td>
</tr>
<tr class="pointDescArea">
<td>טקסט:</td>
<td rowspan="2">
<h1 style="color: gray"><%# Eval("Text") %></h1>
</td>
</tr>
<tr class="hidden">
<td>X:</td>
<td><%# Eval("Lon") %></td>
</tr>
<tr class="hidden">
<td>Y:</td>
<td><%# Eval("Lat") %></td>
</tr>
</tr>
</table>
</div>
</AlternatingItemTemplate>
</asp:Repeater>
I need to set it's height to 500px and make scrollable.
How can I make this repeater scrollable vertically?
Put the repeater inside a div, set the div's height and use overflow-y
<div style="height: 500px; overflow-y: scroll;">
<asp:Repeater ID="PervousResultsList" runat="server" EnableViewState="False" >
...
</asp:Repeater>
</div>
Ideally the styling should be in style tags or in a stylesheet, but I'm showing it inline just for demonstration.
Here I have a table row in a listview declared as follows:
<tr onclick="<%= _jsPostBackCall %>;" />
I am calling a postback method on the backend but must get the tr index:
public void RaisePostBackEvent(string eventArgument)
{
//selected index here
}
aspx page content - below is the html in the aspx page. This contains the listview.
<asp:ListView ID="lvEquipmentList" runat="server" OnSelectedIndexChanged="lvEquipmentList_SelectedIndexChanged" OnSelectedIndexChanging="lvEquipmentList_SelectedIndexChanging">
<LayoutTemplate>
<table runat="server" class="TableCSS">
<tr runat="server" class="TableHeader">
<td runat="server" style="width: 30%;">PRODUCT LINE</td>
<td runat="server" style="width: 20%;">MODEL</td>
<td runat="server" style="width: 20%;">SERIAL #</td>
<td runat="server" style="width: 12%; text-align:center">DAR STATUS</td>
<td runat="server" style="width: 18%; text-align:right;">SHIP DATE</td>
</tr>
<tr id="ItemPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<EmptyDataTemplate>
<table id="Table1" runat="server" class="TableCSS">
<tr runat="server" class="TableHeader">
<td id="Td1" runat="server" style="width: 30%;">PRODUCT LINE</td>
<td id="Td2" runat="server" style="width: 20%;">MODEL</td>
<td id="Td3" runat="server" style="width: 20%;">SERIAL #</td>
<td id="Td4" runat="server" style="width: 12%; text-align:center;">DAR STATUS</td>
<td id="Td5" runat="server" style="width: 18%; text-align:right;">SHIP DATE</td>
</tr>
<tr runat="server" class="TableData">
<td style="column-span:all;">
<asp:Label runat="server" Text="There are no reports to display."></asp:Label>
</td>
</tr>
</table>
</EmptyDataTemplate>
<ItemTemplate>
<tr style="border-bottom:1pt solid #E2E2E8;" onclick="<%= _jsPostBackCall %>;" onmouseover="this.style.background='#f6f6f6';" onmouseout="this.style.background='white'">
<td style="width: 30%; padding: 0px 15px 0px 15px;">
<table>
<tr class="NoBorder">
<td style="width: 20%;">
<img src='<%#Eval("standard_image") %>' alt="" width="80" onerror="this.src='Content/Images/placeholder.png';"/>
</td>
<td>
<asp:Label ID="lblProductLine" runat="server" Text='<%#Eval("product_line")%>'/>
</td>
</tr>
</table>
</td>
<td style="width: 24%; padding: 0px 15px 0px 15px;">
<asp:Label ID="lblModelNum" runat="server" Text='<%#Eval("model")%>'/>
</td>
<td style="width: 16%; padding: 0px 15px 0px 15px;">
<asp:Label ID="lblSerialNum" runat="server" Text='<%#Eval("serial_number")%>'/>
</td>
<td style="width: 12%; padding: 0px 15px 0px 15px; text-align:center;">
<asp:LinkButton runat="server" ID="SelectCategoryButton" CommandName="Select">
<img id="Img1" runat="server" src='<%#Eval("display_status") %>' alt="" width="20"/>
</asp:LinkButton>
</td>
<td style="width: 18%; padding: 0px 15px 0px 15px; text-align:right;">
<asp:Label ID="lblShipDate" runat="server" Text='<%#Eval("date")%>'/>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
When registering postback call - second argument will be the parameter:
_jsPostBackCall = ClientScript.GetPostBackEventReference(this, "The Parameter");
i am a student working in an simple application and i do not know how to use the img tag and i have tryed one such code but while executing the code the image is not showing plz see the code and help me to saw what is the wrong in the code.
code is:
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<table border="0" align="center" cellpadding="0" cellspacing="0" style="width: 100%;
height: 100%;">
<tr style="width: 100%; height: 300px;">
<td valign="middle" align="center">
<img alt="" src="C:\Documents and Settings\temp.intern1\My Documents\My Pictures\images4.jpg" />
</td>
</tr>
<tr style="height: 65%; vertical-align: top;">
<td style="width: 90%;" align="center">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="height: 20px">
</td>
</tr>
<tr>
<td align="center" valign="middle" width="100%" style="height: 100%">
<div id="Panel1" style="background-color: #87BDEF; height: 300px; width: 600px;">
<table cellpadding="0" cellspacing="0" style="height: 400px" width="600px">
<tr>
<td>
</td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0" style="height: 200px" width="600px">
<tr>
<td align="right" style="padding-left: 5px; width: 50%;">
<asp:Label ID="lblUserName" runat="server" Text="USER NAME :"></asp:Label>
</td>
<td align="left" style="padding-left: 5px; width: 50%;">
<br />
<asp:TextBox ID="txtUserName" runat="server" Width="70%"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvUserName" ErrorMessage="Please enter Username"
ControlToValidate="txtUserName" runat="server" Width="70%" ForeColor="red" Style="margin-left: 0px;" />
</td>
</tr>
<tr>
<td>
<br />
</td>
<td>
<br />
</td>
</tr>
<tr>
<td align="right" style="width: 50%;">
<asp:Label ID="lblPassword" runat="server" Text="PASSWORD :"></asp:Label>
</td>
<td align="left" style="padding-left: 5px; width: 50%;">
<br />
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Width="70%"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvPassword" ErrorMessage="Please enter Password"
ControlToValidate="txtPassword" runat="server" Width="70%" ForeColor="red" Style="margin-left: 0px" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<span id="lblInValid" style="color: #C00000; font-family: Verdana; font-size: Small;">
</span>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<table width="50%">
<tr>
<td align="left" style="padding-left: 5px; width: 50%;">
<asp:Button ID="btnSubmit" runat="server" Text="SUBMIT" OnClick="btnSubmit_Click" />
<br />
<br />
<br />
</td>
<td align="left" style="padding-left: 5px; width: 50%;">
<asp:Button ID="btnClear" runat="server" Text="CLEAR" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<br />
</td>
<td>
<br />
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td height="180px">
<br />
</td>
</tr>
<tr>
<td>
<br />
</td>
</tr>
</table>
</td>
</tr>
</table>
</asp:Content>
plz some one help me on this code...,
Your image should be in the folder accessible to your web server. Try including your image into your solution file (assuming you are using Visual Studio), and use relative path, such as "/images/image4.jpg"
Go to some web site (like www.cnn.com), view source for any page and see how they set path to img tags.
You can also use ASP.Net image tag, check out MSDN for examples and usage.
The problem is that you are using an address to an image on your computer, so that will only work when you view the page from that specific computer.
You should copy the image into the web application, for example into a folder named images, then you use that address in the image tag:
<img alt="" src="images/images4.jpg" />
i am using model popup in asp.net on this linkbutton
<asp:LinkButton ID="LinkButton1" runat="server" CssClass="addProduct-disable" Enabled ="false" Text="Assign Filter Criteria" CausesValidation="true" ></asp:LinkButton>
when i click a button in popup the event is getting fired but the asp panel and label are not getting displayed
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td colspan="3" class="style3" align="center">
Assign Filtering Criteria
</td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="lblSuccess" runat="server" Text="" ></asp:Label>
</td>
</tr>
<tr>
<td class="logText" width="30%">
Filter:
<asp:ImageButton ID="imgFilter" runat="server" ImageUrl="../images/helpIcon.png"
border="0" CausesValidation="false" OnClientClick="return showHelp('ctl00_ContentPlaceHolder1_pnlFilterHelp');" />
<cc1:ModalPopupExtender ID="mdlFilter" runat="server" TargetControlID="imgFilter"
PopupControlID="pnlFilterHelp" DropShadow="false" CancelControlID="lnkFilterCancel"
X="410" Y="200" />
<asp:Panel ID="pnlFilterHelp" runat="server" Height="70px" Width="170px" Style="display: none;">
<asp:Panel ID="pnlFilterOuter" runat="server" CssClass="modalPopup2" Height="100px"
Width="180px" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" BackColor="#FFFCF9">
<table cellpadding="0" cellspacing="0" width="90%">
<tr>
<td align="center" valign="middle" style="padding-top: 15px; padding-left: 5px;">
<table cellpadding="0" align="center" cellspacing="0" width="100%" height="40px">
<tr>
<td class="style8">
Set Filter Criteria so that customer can easily search product.
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td style="padding-left: 20px;">
<asp:LinkButton ID="lnkFilterCancel" runat="server" Text="" CssClass="gridPagerlink"
ForeColor="Black">Close <b>X</b></asp:LinkButton>
</td>
</tr>
</table>
</asp:Panel>
</asp:Panel>
</td>
<td width="4px">
</td>
<td class="logBox">
<asp:UpdatePanel ID="filter" runat="server">
<ContentTemplate>
<asp:DropDownList ID="drpFilter" runat="server" AutoPostBack="True" OnSelectedIndexChanged="drpFilter_SelectedIndexChanged"
Width="150px">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td colspan="3">
</td>
</tr>
<tr>
<td class="logText">
Filter Option:
<asp:ImageButton ID="imgFilterOption" runat="server" ImageUrl="../images/helpIcon.png"
border="0" CausesValidation="false" OnClientClick="return showHelp('ctl00_ContentPlaceHolder1_pnlFilterOption');" />
<cc1:ModalPopupExtender ID="mdlFilterOption" runat="server" TargetControlID="imgFilterOption"
PopupControlID="pnlFilterOption" DropShadow="false" CancelControlID="lnkFilterOptionCancel"
X="410" Y="220" />
<asp:Panel ID="pnlFilterOption" runat="server" Height="70px" Width="170px" Style="display: none;">
<asp:Panel ID="pnlFilterOptionOuter" runat="server" CssClass="modalPopup2" Height="300px"
Width="580px" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" BackColor="#FFFCF9">
<table cellpadding="0" cellspacing="0" width="90%">
<tr>
<td align="center" valign="middle" style="padding-top: 15px; padding-left: 5px;">
<table cellpadding="0" align="center" cellspacing="0" width="100%" height="40px">
<tr>
<td class="style8">
Set Filter Criteria Option so that customer can easily search product.
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td style="padding-left: 20px;">
<asp:LinkButton ID="lnkFilterOptionCancel" runat="server" Text="" CssClass="gridPagerlink"
ForeColor="Black">Close <b>X</b></asp:LinkButton>
</td>
</tr>
</table>
</asp:Panel>
</asp:Panel>
</td>
<td width="4px">
</td>
<td class="logBox">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="drpFilterOption" runat="server" Width="150px" Enabled="false">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td colspan="3">
</td>
</tr>
<tr>
<td class="logText">
</td>
<td width="4px">
</td>
<td class="logBox">
<asp:UpdatePanel ID="cancel" runat="server">
<ContentTemplate>
<asp:Button ID="btnAdd" runat="server" Style="font-weight: 700; text-align: right"
Text="Add" CssClass="Login-btn" OnClick="btnAdd_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</td> </tr>
<tr>
<td>
</td>
<td colspan="2">
</td>
</tr>
<tr>
<td align="center" colspan="3">
<asp:Panel ID="pnlAddFilter" runat="server" style="display:none">
<table id="list">
</table>
<div id="pager" style="text-align: center;">
</div>
<br />
</asp:Panel>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
</tr>
</table>
event is
protected void btnAdd_Click(object sender, EventArgs e)
{
pnlAddFilter.Style.Add("display", "block");
//pnlAddFilter.Visible = true;
DataTable dtFilter = new DataTable();
dtFilter.Columns.Add("FOId");
dtFilter.Columns.Add("Filtername");
dtFilter.Columns.Add("FilterOption");
DataRow drFilter;
if (Session["Filter"] != null)
{
dtFilter = (DataTable)Session["Filter"];
}
drFilter = dtFilter.NewRow();
drFilter["FOId"] = drpFilterOption.SelectedValue;
drFilter["Filtername"] = drpFilter.SelectedItem.Text;
drFilter["FilterOption"] = drpFilterOption.SelectedItem.Text;
dtFilter.Rows.Add(drFilter);
Session["Filter"] = dtFilter;
btnAdd.Enabled = false;
if (Session["Filter"] == null)
{
// pnlAddFilter.Visible = false;
pnlAddFilter.Style.Add("display", "none");
}
else
{
pnlAddFilter.Style.Add("display", "block");
// pnlAddFilter.Visible = true;
}
lblSuccess.Visible = true;
lblSuccess.Text = AppHardcodeValue.strAddFilterProduct;
}
In my experience, the modal popup doesn't support dynamically rendered data very well. I'm thinking you probably need to put your modal content inside of an update panel in order to be able to use the server side code to update the label.