PlaceHolder using Listview Error - asp.net

Below is my markup code which upon compiling gives me the error message.I have searchd for hours in google but cannot help myself.What is the incoorect code in my markup.
I have a cs file for this pagewhich binds data to this listview conrol
Any help to fix this will be greatly helpful
Error Message:An item placeholder must be specified on ListView 'listview1'. Specify an item placeholder by setting a control's ID property to "itemContainer". The item placeholder control must also specify runat="server".
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Attestation2.aspx.cs" Inherits="Attestation2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body style="z-index: 1; left: 21px; top: 0px; position: absolute; height: 313px;
width: 983px">
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="Entitlementdlist" runat="server" AutoPostBack="true" Visible="true"
ToolTip="All the Requests in this dropdown are Entitlement Requests only">
</asp:DropDownList>
<%--asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>--%>
<asp:ListView ID="listview1" runat="server" ItemPlaceholderID="itemplaceholder" >
<ItemTemplate>
<table style="border:1px solid black;">
<tr>
<td>Report Name</td>
<td><asp:TextBox ID="ReportNameLbl" runat="server" Text='<%#Eval("REPORT_DESCRIPTION.rptdesctext") %>' Width="500"></asp:TextBox> </td>
<td>
<asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Text="Yes" Value="Yes"></asp:ListItem>
<asp:ListItem Text="No" Value="No"></asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td>Content Description</td>
<td>
<asp:Label ID="ContentDescLbl" Text='<%#Eval("REPORT_REQUEST.StopLossMax") %>' runat="server" ></asp:Label>
</td>
<td>
<asp:CheckBoxList ID="CheckBoxList2" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Text="Yes" Value="Yes"></asp:ListItem>
<asp:ListItem Text="No" Value="No"></asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td>
Frequency
</td>
<td>
<asp:Label ID="frequencyLbl" Text='<%#Eval("REPORT_REQUEST.reportfrequency") %>' runat="server" ></asp:Label>
</td>
<td>
<asp:CheckBoxList ID="CheckBoxList3" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Text="Yes" Value="Yes"></asp:ListItem>
<asp:ListItem Text="No" Value="No"></asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td>
Recepients
</td>
<td colspan="2">
<td>
<asp:ListView ID = "lstview2" runat = "server" >
</asp:ListView>
</td>
</td>
</tr>
</table>
</asp:Table>--%>
</ItemTemplate>
</asp:ListView>
</div>
</form>
</body>
</html>

Inside your ListView you've to add a LayoutTemplate containing the PlaceHolder:
<asp:ListView ID="listview1" runat="server" ItemPlaceholderID="itemplaceholder" >
<LayoutTemplate>
<asp:PlaceHolder ID="itemplaceholder" runat="server" />
</LayoutTemplate>
<ItemTemplate>
...
</ItemTemplate>
</asp:ListView>

Related

Bind 3 items in each row of a repeater VB.net

I have this code that creates a check box an image and a label.
I want to view only three cells in each row, how can I do that??
<table class="checkbox-container" style="margin-top: 15px; width: 50%;">
<tr>
<asp:Repeater EnableViewState="true" ID="rptStart" runat="server">
<ItemTemplate>
<td style="width:25%;">
<asp:CheckBox ID="chkColor" runat="server" />
<img id="imgCompStatusStar" runat="server" enableviewstate="false" src="../images/" />
<asp:Label id="lblStarDescription" class="floating-left" runat="server" CssClass="test"/>
</td>
</ItemTemplate>
</asp:Repeater>
</tr>
</table>
Change your markup to this:
<asp:Repeater EnableViewState="true" ID="rptStart" runat="server">
<HeaderTemplate>
<table>
<tr>
</HeaderTemplate>
<ItemTemplate>
<%#If((Container.ItemIndex <> 0 AndAlso Container.ItemIndex Mod 3 = 0), "</tr><tr>", String.Empty)%>
<td style="width: 25%;">
<asp:CheckBox ID="chkColor" runat="server" />
<img id="imgCompStatusStar" runat="server" enableviewstate="false" src="../images/" />
<asp:Label ID="lblStarDescription" class="floating-left" runat="server" CssClass="test" />
</td>
</ItemTemplate>
<FooterTemplate>
</tr></table>
</FooterTemplate>

Get the id of parent listview in child listview checkbox change event

On chkSubModuleView_CheckedChanged() event iwant to get the id of chkModule.Please tell me how to get the id or reference of parent checkbox on click of child checkbox in server side.How to distinguish between different modules .
enter code here
<asp:ListView ID="lvModule" runat="server">
<LayoutTemplate>
<table width="600px" border="0" cellpadding="0" cellspacing="0"
class="ListViewtable">
<tr>
<th style="width: 10%;">
Modules
</th>
</tr>
<asp:PlaceHolder ID="itemPlaceholder" runat="server">
</asp:PlaceHolder>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<asp:CheckBox ID="chkModule" runat="server"
CausesValidation="false" AutoPostBack="true"
OnCheckedChanged="chkModule_CheckedChanged" >
</asp:CheckBox><asp:HiddenField ID="hfEntityName"
Value='<%# Eval("EntityName") %>' runat="server" />
<%# Eval("Title")%>
<asp:HiddenField ID="hfID" Value='<%# Eval("ID") %>'
runat="server" />
<asp:Label ID="label" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2" style="padding-left: 20px;">
<asp:ListView ID="lvSubModule" runat="server">
<LayoutTemplate>
<table width="100%" cellspacing="0" border="0"
class="ListViewtableLayer2">
<tr>
<th style="width: 20%;">
Sub Module
</th>
<th style="width: 20%;">
<asp:CheckBox ID="chkSubModuleView"
Checked="true" runat="server" AutoPostBack="true"
OnCheckedChanged="chkSubModuleView_CheckedChanged" />
View
</th>
</tr>
<asp:PlaceHolder ID="itemPlaceholder"
runat="server"></asp:PlaceHolder>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<%# Eval("Title")%>
<asp:HiddenField ID="hfMenuID" Value='<%#
Eval("MenuID") %>' runat="server" />
<asp:HiddenField ID="hfName" Value='<%#
Eval("HeaderID") %>' runat="server" />
</td>
<td>
<asp:CheckBox ID="chkRead" runat="server"
AutoPostBack="true" Checked="true" CausesValidation="false"
OnCheckedChanged="chkRead_CheckedChanged"></asp:CheckBox>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
change your checkbox property to
<asp:CheckBox ID="chkSubModuleView"
Checked="true" runat="server" AutoPostBack="true" Key='<%# Eval("ID")%>'
OnCheckedChanged="chkSubModuleView_CheckedChanged" />
In your .cs
protected void chkSubModuleView_CheckedChanged(object sender, EventArgs e)
{
CheckBox chk = (CheckBox)sender;
string yourID = chk.Attributes["Key"].ToString();
}

Get row/column of 3 deep nested Listivew on textbox OnTextChanged

I am attempting to get the row and column location of a text boxes OntextChanged.
I can get the column location if I do this:
TextBox txtScore = sender;
ListViewItem item = (ListViewItem)txtScore.NamingContainer;
int col = ((ListView)item.NamingContainer).DataKeys(item.DataItemIndex).Values(0);
which works until I convert the snippet below to a user control.
Code Snippet
<asp:ListView ID="techs" runat="server" ItemPlaceholderID="lvItemPlaceholder" DataKeyNames="Number"
OnItemDataBound="techs_ItemDataBound">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="lvItemPlaceholder" />
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
Tech
<%# Eval("Number")%>
</td>
<td>
<asp:TextBox ID="tech" runat="server" Text='<%# Eval("Name") %>' />
</td>
<asp:ListView ID="scorePatterns" runat="server" ItemPlaceholderID="lvScorePatternsItemPlaceholder"
OnItemDataBound="scorePatterns_ItemDataBound" DataKeyNames="Ref">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="lvScorePatternsItemPlaceholder" />
</LayoutTemplate>
<ItemTemplate>
<td>
<table>
<asp:ListView ID="scores" runat="server" ItemPlaceholderID="lvScoresItemPlaceholder"
OnItemDataBound="scores_ItemDataBound" DataKeyNames="Ref,Instance">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="lvScoresItemPlaceholder" />
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<asp:TextBox runat="server" ID="txtScore" Width="50" AutoPostBack="true" OnTextChanged="txtScore_TextChanged" />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
</table>
</td>
</ItemTemplate>
</asp:ListView>
<td>
<asp:Label runat="server" ID="lblDate" Text='<%# Eval("Date") %>' />
</td>
</tr>
</ItemTemplate>

AutoCompleteExtender position is wrong not directly under textbox

My AutoCompleteExtender works except that the extender is in the wrong position it's to far down
i tried this link here but it didn't work this is in ie browser
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="Email">Email</asp:ListItem>
<asp:ListItem Value="UserName">User Name</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="TxtSearch" runat="server"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="AutoComplete1" runat="server" BehaviorID="AutoCompleteEx"
TargetControlID="TxtSearch" ServicePath="~/CMSWebServices/MemberService.asmx" ServiceMethod="SearchUsersByName"
MinimumPrefixLength="2" CompletionInterval="500" EnableCaching="true" CompletionSetCount="12" CompletionListElementID="TxtSearchPosition">
</ajaxToolkit:AutoCompleteExtender>
<ul id="TxtSearchPosition"></ul>
</td>
<td>
<asp:Button ID="ButtonSearch" runat="server" Text="Search" />
</td>
</tr>
</table>

Ajax ModelpopupExtender Cant work

I am using modelpopupextender in asp.net and this code is working window is popup sucessfuly but cancel button can't work; can anybody tell me why?
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp"
%>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:Button ID="buttonOpen" runat="server" style="display:none" ></asp:Button>
<asp:Panel ID="Panel3" runat="server" BackColor="#99CCFF" Height="269px" Width="350px"
style="display:none">
<table width="100%" style="border:Solid 3px #D55500; width:100%; height:100%"
cellpadding="0" cellspacing="0">
<tr style="background-color:#333399">
<td colspan="2" style=" height:10%; color:White; font-weight:bold; font-size:larger"
align="center">Time Details</td>
</tr>
<tr>
<td>
<asp:Label ID="Label19" runat="server" Text="Time From"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label20" runat="server" Text="Time To"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label21" runat="server" Text="Number of Slots"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" runat="server" Text="Add" />
</td>
<td>
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
</td>
</tr>
</table>
</asp:Panel>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" OnCancelScript="btnCancel" PopupControlID="panel3" TargetControlID="buttonOpen" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>
You need to set the CancelControlID property, not the OnCancelScript property (unless you want to execute a script after the cancel button is clicked). So for your scenario, do this:
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" CancelControlID="btnCancel" PopupControlID="panel3" TargetControlID="buttonOpen" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>

Resources