I am trying to use a repeater inside an AjaxToolKit Accordion. This is necessary because I need pagination within my DataList using a SQL stored procedure. It works fine if I place the repeater outside of the AjaxToolKit Accordion, but I need to place the repeater inside the accordion. I am accessing the inner repeater (from code-behind) by placing an outer repeater outside of my Ajax Accordion. However, I'm still getting an error:
Type 'System.Web.UI.WebControls.Repeater' does not have a public property named 'Accordion'.
Here is my asp.net webform:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:Repeater ID="RepeaterOutside" runat="server">
<ajaxToolkit:Accordion ID="Accordion1" runat="server" HeaderCssClass="accordion" ContentCssClass="accordion" HeaderSelectedCssClass="accordion" FadeTransitions="true" TransitionDuration="500" AutoSize="None" SelectedIndex="-1" RequireOpenedPane="false">
<Panes>
<ajaxToolkit:AccordionPane ID="AccordionPane1" runat="server">
<Header>
<p>Click selection for details.</p>
<div class="panel panel-default">
<div class="alertHeading" style="color: red; background-color: lightgray; font-weight: 700; padding: 1em; border-radius: 5px; border: dashed 1px; border-color: black;">ACCOUNT DETAILS</div>
</div>
</Header>
<Content>
<div id="titleAccountResults" runat="server" visible="true">
<div class="form-group">
<h6>Account Details:</h6>
</div>
</div>
<asp:DataList ID="DataListAccount" runat="server">
<ItemTemplate>
<tr>
<td style="width: 171px">Account Number:</td>
<td style="width: 220px">
<asp:Label ID="lblAccountNumber" runat="server" Text='<%# Eval("ACCOUNT_NUMBER") %>'></asp:Label>
</td>
</tr>
<asp:PlaceHolder ID="PlaceHolder36" runat="server" Visible='<%# !string.IsNullOrEmpty(Eval("ACCOUNT_STATUS").ToString()) ? true : false %>'>
<tr id="rowAccountStatusAccount">
<td style="width: 171px">Account Status:</td>
<td style="width: 220px">
<asp:Label ID="lblAccountStatus" runat="server" Text='<%# Eval("ACCOUNT_STATUS") %>'></asp:Label>
</td>
</tr>
</asp:PlaceHolder>
<asp:PlaceHolder ID="PlaceHolder35" runat="server" Visible='<%# !string.IsNullOrEmpty(Eval("ACCOUNT_NAME").ToString()) ? true : false %>'>
<tr id="rowAccountNameAccount" runat="server">
<td style="width: 171px">Account Name:</td>
<td style="width: 220px">
<asp:Label ID="lblAccountName" runat="server" Text='<%# Eval("ACCOUNT_NAME") %>'></asp:Label>
</td>
</tr>
</asp:PlaceHolder>
</ItemTemplate>
</asp:DataList>
</Content>
</ajaxToolkit:AccordionPane>
</Panes>
<HeaderTemplate>
<hr />
</HeaderTemplate>
<Panes>
<ajaxToolkit:AccordionPane ID="AccordionPane2" runat="server">
<Header>
<div class="panel panel-default">
<div class="alertHeading" style="color: red; background-color: lightgray; font-weight: 700; padding: 1em; border-radius: 5px; border: dashed 1px; border-color: black;">PAYMENT DETAILS</div>
</div>
</Header>
<Content>
<div id="Div1" runat="server" visible="true">
<div class="form-group">
<h6>Contact Details:</h6>
</div>
</div>
<asp:DataList ID="DataListContact" runat="server">
<ItemTemplate>
<tr>
<td style="width: 171px">Account Number:</td>
<td style="width: 220px">
<asp:Label ID="lblAccountNumber" runat="server" Text='<%# Eval("ACCOUNT_NUMBER") %>'></asp:Label>
</td>
</tr>
<asp:PlaceHolder ID="" runat="server" Visible='<%# !string.IsNullOrEmpty(Eval("COMPANY_NAME").ToString()) ? true : false %>'>
<tr>
<td style="width: 171px">Company Name:</td>
<td style="width: 220px">
<asp:Label ID="lblCompanyName" runat="server" Text='<%# Eval("COMPANY_NAME") %>'></asp:Label>
</td>
</tr>
</asp:PlaceHolder>
<asp:PlaceHolder ID="" runat="server" Visible='<%# !string.IsNullOrEmpty(Eval("COMPANY_ADDRESS").ToString()) ? true : false %>'>
<tr>
<td style="width: 171px">Address:</td>
<td style="width: 220px">
<asp:Label ID="" runat="server" Text='<%# Eval("COMPANY_ADDRESS") %>'></asp:Label>
</td>
</tr>
</asp:PlaceHolder>
<asp:Repeater ID="rptPager" runat="server">
<ItemTemplate>
<asp:Button ID="lnkPage" class="btn btn-outline-primary" runat="server" Text='<%#Eval("Text") %>' CommandArgument='<%# Eval("Value") %>'
CssClass='<%# Convert.ToBoolean(Eval("Enabled")) ? "page_enabled" : "page_disabled" %>'
OnClick="Page_Changed" OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>'></asp:Button>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:DataList>
</Content>
</ajaxToolkit:AccordionPane>
</Panes>
</ajaxToolkit:Accordion></asp:Repeater></asp:Content>
I found the solution. Place the repeater inside separate content tags and within the accordion's content tags. Also, no need to call the repeater by an outside repeater through code behind as stated above. I removed the outside repeater. It's working now.
<content>repeater goes here</content>
Related
I am using repeater and I want to find the label control in my repeater. here is my code
<asp:Repeater ID="friendRepeater" runat="server">
<table cellpadding="0" cellspacing="0">
<ItemTemplate>
<tr style=" width:700px; height:120px;">
<td>
<div style=" padding-left:180px;">
<div id="leftHandPost" style="float:left; width:120px; height:120px; border: medium solid #cdaf95; padding-top:5px;">
<div id="childLeft" style=" padding-left:5px;">
<div id="photo" style=" border: thin solid black; width:100px;height:100px;">
<asp:Image id="photoImage" runat="server" ImageUrl='<%# String.Concat("Images/", Eval("Picture")) %>' Width="100px" Height="100px" />
</div>
</div><!--childLeft-->
</div><!--leftHandPost-->
</div>
</td>
<td>
<div id="rightHandPost" style=" float:right; padding-right:260px;">
<div id="childRight" style="width:400px; height:120px; border: medium solid #cdaf95; padding-top:5px; padding-left:10px;">
<strong><asp:Label id="lblName" runat="server"><%# Eval("PersonName") %></asp:Label></strong><br />
<div style=" float:right; padding-right:10px;"><asp:Button runat="server" Text="Add" onClick="add" /></div><br />
<asp:Label id="lblID" runat="server"><%# Eval("PersonID") %></asp:Label><br />
<asp:Label id="lblEmail" runat="server"><%# Eval("Email") %></asp:Label>
</div><!--childRight-->
</div><!--rightHandPost-->
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style=" width:700px; height:120px;">
<td>
<div style=" padding-left:180px;">
<div id="Div1" style="float:left; width:120px; height:120px; border: medium solid #cdaf95; padding-top:5px;">
<div id="Div2" style="padding-left:5px;">
<div id="Div3" style=" border: thin solid black; width:100px;height:100px;">
<asp:Image id="photoImage" runat="server" ImageUrl='<%# String.Concat("Images/", Eval("Picture")) %>' Width="100px" Height="100px" />
</div>
</div><!--childLeft-->
</div><!--leftHandPost-->
</div>
</td>
<td>
<div id="Div4" style=" float:right; padding-right:260px;">
<div id="Div5" style="width:400px; height:120px; border: medium solid #cdaf95; padding-top:5px; padding-left:10px;">
<strong><asp:Label id="lblName" runat="server"><%# Eval("PersonName")%></asp:Label></strong>
<div style=" float:right; padding-right:10px;"><asp:Button id="btnAdd" runat="server" Text="Add" onClick="add"></asp:Button></div><br />
<br />
<asp:Label id="lblID" runat="server"><%# Eval("PersonID") %></asp:Label><br />
<asp:Label id="lblEmail" runat="server"><%# Eval("Email") %></asp:Label>
</div><!--childRight-->
</div><!--rightHandPost-->
</td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
Here is the code behind for the add button.
protected void add(object sender, EventArgs e)
{
DateTime date = DateTime.Now;
System.Web.UI.WebControls.Label la = (System.Web.UI.WebControls.Label)friendRepeater.FindControl("PersonID");
String id = la.Text;
try
{
MySqlConnection connStr = new MySqlConnection();
connStr.ConnectionString = "Server = localhost; Database = healthlivin; Uid = root; Pwd = khei92;";
String insertFriend = "INSERT INTO contactFriend(friendID, PersonID, PersonIDB, date) values (#id, #personIDA, #personIDB, #date)";
MySqlCommand cmdInsertStaff = new MySqlCommand(insertFriend, connStr);
cmdInsertStaff.Parameters.AddWithValue("#id", "F000004");
cmdInsertStaff.Parameters.AddWithValue("#personIDA", "M000001");
cmdInsertStaff.Parameters.AddWithValue("#personIDB", id);
cmdInsertStaff.Parameters.AddWithValue("#date", date);
connStr.Open();
cmdInsertStaff.ExecuteNonQuery();
MessageBox.Show("inserted");
connStr.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
I have get the error of Object reference not set to an instance of an object. I think is because there are no value in the Label. The Find Control are not working. May I know how can fix this problem? Thank you very much
foreach (RepeaterItem item in friendRepeater.Items)
{
Label lab = item.FindControl("lblName") as Label;
}
I think you can use this:
var personId= (Label)friendRepeater.Items[0].FindControl("PersonID");
The problem is you don't have any Label names "personID", so it couldn't find that control.
I assume that you want to get value from this line
<asp:Label id="lblID" runat="server"><%# Eval("PersonID") %></asp:Label>
And this Label control names "lblID", so your query code should be
System.Web.UI.WebControls.Label la = (System.Web.UI.WebControls.Label)friendRepeater.FindControl("lblID");
Use lblID to find control instead of PersonID
This worked for me.
Label lblperson = (Label)(rpfrndRepeater.Items[0]).FindControl("lblPerson");
I am trying to make the row background color change when moseover, but I could not make it work. I am not sure I use OnItemDataBound is correct or my codebehind is incorrect.
Please help. Thanks!
<asp:DataList BackColor="#ffffff" id="DataList1" DataSourceID="dsCompanyListPartialMatch" runat="server" Width="80%" DataKeyField="Company1Word"
UseAccessibleHeader="true"
CssClass="books"
HeaderStyle-CssClass="header"
ItemStyle-CssClass="item"
AlternatingItemStyle-CssClass="alternating"
GridLines="Both"
CellPadding="0"
CellSpacing="0" BorderColor="Black"
ItemStyle-BorderColor="Black" BorderWidth="0"
HorizontalAlign="Center"
RepeatDirection="Vertical"
OnItemDataBound="DataList1_ItemDataBound"
>
<HeaderTemplate>
</HeaderTemplate>
<ItemStyle BorderColor="black" Font-Size="Medium" />
<ItemTemplate>
<table border="0">
<tr>
<td style="width: 50px; border-right:1px solid black; border-spacing:0; text-align:center; ">
<asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" Text="+" CommandArgument='<%#Container.ItemIndex%>'
OnCommand="LinkButton1_Command"
Font-Underline="false"
Height="25"
Font-Bold="true"
></asp:LinkButton>
</td>
<td style="width: 50px; border-right:1px solid black; border-spacing:0;"><%#Eval("Row")%></td>
<td style="width: 800px"><asp:Literal ID="litFoo" runat="server" Text='<%#Eval("Company")%>' /> </td>
<td style="width: 600px; text-align:right;">
<asp:CheckBox id="check1" runat="server" />
</td>
<asp:Label ID="lblRow" Visible="False" runat="Server" Text='<%# DataBinder.Eval(Container.DataItem, "Row") %>' />
</tr>
</table>
<asp:Panel ID="pnlChildView" runat="server" style="padding-left:200px;">
<asp:DataList ID="childList" runat="server" Width="100%">
<ItemTemplate>
<table class="table1" border="1">
<tr>
<td style="width: 800px; border-right:0px solid black; border-spacing:0;">• <%#Eval("CompanyName")%></td>
<td style="text-align:right; "><a href="/Apps/ERP/Other/CompanyInfo.asp?CompanyID=<%#Eval("CompanyID")%>" ><%#Eval("CompanyID")%></a></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</asp:Panel>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:DataList>
Code behind
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item)
{
e.Item.Attributes.Add("onmouseover", "this.className='BGMouseOver'");
e.Item.Attributes.Add("onmouseout", "this.className='BGMouseOut'");
}
}
Try jQuery mouseover() Method
Click here
I suggest CSS. You can find the idea here: div background color, to change onhover
Add CSS to the top:
<style type="text/css">
.div_hover:hover { background-color: #000000; } <-- this is where you set your hover color
</style>
Basically, wrap everything in your ItemTemplate in a div, like so:
<ItemTemplate>
<div class="div_hover">
[ItemTemplate stuff...]
</div>
</ItemTemplate>
I have a webpage that is setup like so:
There is a ListView that has an item for each record in one of our SQL tables. Each of these items has a CollapsiblePanel in it that can be expanded to show more detail about the given record.
My Issue:
When I expand one panel and then wait for it to complete...everything is okay. However, if I try to expand multiple of those collapsiblepanels at once (meaning before the first panel is completely expanded)...only the last panel expands showing its data.
My Question:
Is it possible to have each of these panels expand asynchronously? Seems silly that I have to wait for one panel to extend before I can extend another.
My aspx:
I modified this aspx a little bit by removing unneeded code to make it less confusing.
<asp:UpdatePanel ID="UpdPnlBGList" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<div class="content-box">
<asp:Panel ID="pnlBGResult" runat="server">
<asp:ListView ID="lvSummary" runat="server" ItemPlaceholderID="placeholderBGList"
OnItemDataBound="lvSummary_ItemDataBound" OnItemCommand="lvSummary_ItemCommand">
<LayoutTemplate>
<table runat="server" id="tblList" cellpadding="0" cellspacing="0" border="0" style="table-layout: fixed;">
<tr id="placeholderBGList" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td>
<asp:UpdatePanel ID="UpdBgItemTemplate" runat="server" ChildrenAsTriggers="true"
UpdateMode="Conditional">
<ContentTemplate>
<div class="bgList">
<asp:Panel ID="pnlSummary" runat="server">
<table id="tblBgList" runat="server" cellpadding="0" cellspacing="0" border="0" style="border-collapse: collapse;
border-spacing: 0px;">
<tr>
<td class="imageColumn">
<asp:ImageButton ID="imgCollapsible" CssClass="first" ImageUrl="~/Images/branding/plus.gif"
runat="server" CommandName="ExpandCollapse" Style="cursor: pointer; padding-right: 5px;" />
</td>
<td width="600px">
<asp:Label ID="lblBGName" runat="server" Text='<%# Eval("BGName")%>' CssClass="bgName"></asp:Label>
<asp:Label ID="lblDatePosted" runat="server" CssClass="datePosted"></asp:Label>
</td>
<td colspan="2">
<div style="float: right;">
<asp:Label ID="lblAccountNumber" runat="server" CssClass="accountReview"></asp:Label>
<asp:Label ID="lblAccountNumberText" runat="server" CssClass="accountReview"></asp:Label>
</div>
</td>
</tr>
<tr>
<td>
</td>
<td width="600px">
<asp:Label ID="lblBillToAddress" runat="server" Text='<%# Eval("BillToAddress")%>'
CssClass="billToAddress" Style="font-weight: bold;"></asp:Label>
</td>
<td>
<div style="float: right;">
<asp:ImageButton ID="imgViewAuthLetter" ImageUrl="~/Images/branding/document.jpeg"
CssClass="first" runat="server" OnClick="imgViewAuthLetter_Click" />
<asp:LinkButton ID="lnkAuthorizationLetter" runat="server" Text="View authorization letter"
class="link_button" OnClick="lnkAuthorizationLetter_Click" OnClientClick="dirtySuppress();"
OnPreRender="addTrigger_PreRender" />
</div>
</td>
<td width="70px" style="float: right;">
<div style="float: right;">
<asp:HyperLink ID="lnkExportImage" runat="server" ImageUrl="/Images/branding/export.jpg"
CssClass="hiperlinkExport" OnClick="dirtySuppress();" />
<asp:HyperLink ID="lnkExportText" runat="server" Text="Export" CssClass="hiperlinkExport"
OnClick="dirtySuppress(); precheckURL(this.href); return false;" />
</div>
</td>
</tr>
<tr>
<td colspan="4" style="padding: 0px;">
<asp:Panel Style="margin-left: 50px;" ID="pnlDetails" runat="server">
<of:AccountNumberListControl ID="accountNumberList" runat="server"></of:AccountNumberListControl>
</asp:Panel>
<cc1:CollapsiblePanelExtender ID="cpe" runat="Server" TargetControlID="pnlDetails"
CollapsedSize="0" Collapsed="True" ExpandControlID="imgCollapsible" CollapseControlID="imgCollapsible"
AutoCollapse="False" AutoExpand="False" ScrollContents="false" ImageControlID="imgCollapsible"
ExpandedImage="~/Images/branding/minus.gif" CollapsedImage="~/Images/branding/plus.gif"
ExpandDirection="Vertical" />
</td>
</tr>
<tr>
<td>
</td>
<td colspan="3" style="padding: 0px;">
<div class="itemSeperator" id="divItemSeperator" runat="server">
</div>
</td>
</tr>
</table>
</asp:Panel>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<asp:HiddenField ID="hdfAccountNumberListControlID" runat="server" Value="" />
<asp:HiddenField ID="hdfAccountNumerID" runat="server" Value="" />
</asp:Panel>
</div>
<of:CustomerSetupExportPopInControl ID="customerSetupExportPopIn" runat="server" />
</ContentTemplate>
My codebehind:
This is the code that is executed when you expand the panel. There are several controls that is populated.
private void ExpandBillingGroup(ListViewDataItem item)
{
Label accountNumberLabel;
Label accountNumberText;
HtmlControl itemSeperator;
AccountNumberListControl accountNumberList;
// set properties for fedex account number label and text.
accountNumberLabel = (Label)item.FindControl("lblAccountNumber");
accountNumberLabel.Text = "FedEx account number: ";
accountNumberLabel.CssClass = "fedExAccountNumberLabel";
accountNumberText = (Label)item.FindControl("lblAccountNumberText");
accountNumberText.Text = lvSummary.DataKeys[item.DisplayIndex].Values["FedExAccountNumber"].ToString();
accountNumberText.CssClass = "fedExAccountNumberText";
//set the properties for Export
var lnkExportImage = (HyperLink)item.FindControl("lnkExportImage");
lnkExportImage.Visible = true;
var lnkExportText = (HyperLink)item.FindControl("lnkExportText");
lnkExportText.Visible = true;
//When expanded populate Customer Setup Export control
customerSetupExportPopIn.BillingGroupID = lvSummary.DataKeys[item.DisplayIndex].Values["BillingGroupID"].ToString();
//When expanded populate AccountNumberlistControl
accountNumberList = (AccountNumberListControl)item.FindControl("accountNumberList");
if (accountNumberList != null)
{
//since we make the AccountNumberListControl not visible on collapse we have to make it visible when we expand
accountNumberList.Visible = true;
//Set the properties
accountNumberList.BillingGroupID = lvSummary.DataKeys[item.DisplayIndex].Values["BillingGroupID"].ToString();
accountNumberList.FedExAccountNumber = lvSummary.DataKeys[item.DisplayIndex].Values["FedExAccountNumber"].ToString();
accountNumberList.BillingGroupName = ((Label)lvSummary.Items[item.DisplayIndex].FindControl("lblBGName")).Text;
accountNumberList.BillToAddress = ((Label)lvSummary.Items[item.DisplayIndex].FindControl("lblBillToAddress")).Text;
accountNumberList.FirstItemNeedsToExpand = BillingGroupIsResolved;
accountNumberList.GetListOfAccountNumbers(lvSummary.DataKeys[item.DisplayIndex].Values["BillingGroupID"].ToString(), VendorID);
}
//set the properties for itemSepeartor
itemSeperator = (HtmlControl)item.FindControl("divItemSeperator");
itemSeperator.Attributes.Add("class", "itemSeperatorExpanded");
UpdatePanel upd = (UpdatePanel)item.FindControl("UpdBgItemTemplate");
upd.Update();
}
Thanks,
Holt
EDIT: Fixed grammar and title issues
the code :
<telerik:RadListView ID="RadListView1" Width="100%" AllowPaging="True" runat="server"
Skin="Metro" allowsorting="true" ItemPlaceholderID="ProductsHolder" DataKeyNames="Product_ID" GroupPlaceholderID="CategoryHolder"
GroupItemCount="4" >
<GroupTemplate>
<fieldset style="float: left; width: 330px; margin-right: 15px;">
<legend><%#Eval("CATEGORY_NAME") %></legend>
<table>
<tr>
<td>
<asp:Panel ID="CategoryHolder" runat="server"></asp:Panel>
</td>
</tr>
</table>
</fieldset>
</GroupTemplate>
<LayoutTemplate>
<fieldset style="width: 100%; margin: 0 auto; border: none;" id="FieldSet1">
<telerik:RadDataPager ID="RadDataPager2" runat="server" PagedControlID="RadListView1"
Visible='<%# Container.PageCount != 1%>' Skin="Metro" PageSize="52">
<Fields>
<telerik:RadDataPagerButtonField FieldType="FirstPrev" FirstButtonText="First" PrevButtonText="Prev"
HorizontalPosition="LeftFloat" />
<telerik:RadDataPagerButtonField FieldType="Numeric" />
<telerik:RadDataPagerButtonField FieldType="NextLast" NextButtonText="Next" LastButtonText="Last"
HorizontalPosition="RightFloat" />
</Fields>
</telerik:RadDataPager>
<br />
<asp:Panel ID="ProductsHolder" runat="server">
</asp:Panel>
<table cellpadding="0" cellspacing="4" width="100%;" style="clear: both;">
<tr>
<td>
<telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="RadListView1"
Visible='<%# Container.PageCount != 1%>' Skin="Metro" PageSize="52">
<Fields>
<telerik:RadDataPagerButtonField FieldType="FirstPrev" FirstButtonText="First" PrevButtonText="Prev"
HorizontalPosition="LeftFloat" />
<telerik:RadDataPagerButtonField FieldType="Numeric" HorizontalPosition="NoFloat" />
<telerik:RadDataPagerButtonField FieldType="NextLast" NextButtonText="Next" LastButtonText="Last"
HorizontalPosition="RightFloat" />
</Fields>
</telerik:RadDataPager>
</td>
</tr>
</table>
</fieldset>
</LayoutTemplate>
<EmptyDataTemplate>
<div style="width: 100%; text-align: center;">
<b>No Results Found</b></div>
</EmptyDataTemplate>
<ItemTemplate>
<div style="float: left; padding-bottom: 20px; padding-left: 10px; padding-right: 10px;">
<div class="CardItem" style="margin: auto !important;">
<div class="cardDisplay">
<img src="../App_Themes/VivaTheme/images/loading_big.gif" alt="" onerror="javascript:this.onerror = null;this.src='../images/Orders/VivaNotAvailable.jpg';"
onload="RetrievePicture(this,'<%# Eval("PRODUCT_ID")%>');" class="lof-image"
width="180" height="117" style="margin-bottom: 5px;" />
</div>
<div class="points">
<%# DataBinder.Eval(Container.DataItem, "SALES_PRICE", "{0:###,###,###,##0.00}") + " " + Eval("CURRENCY_ABREVIATION")%>
</div>
<hr class="fleft" style="border: 1px solid #D9E1E3; width: 195px;" />
<div class="CardItemDesc">
<table width="100%" style="display: inline-block;">
<tr>
<td>
<%# Eval("PRODUCT_NAME")%>
</td>
</tr>
<tr>
<td>
<telerik:RadRating ID="RadRating1" Skin="Metro" runat="server" Enabled="false" Value='<%# Double.Parse(Eval("SALES_PRICE").ToString()) % 3 +2 %>'>
</telerik:RadRating>
</td>
</tr>
<tr>
<td>
<img src="../images/Orders/AddToCart.png" alt="Add to Cart" height="23" onclick="AddToCart(this, '<%# Eval("PRODUCT_NAME")%>', '<%# Eval("SALES_PRICE") %>', '<%# Eval("CURRENCY_ABREVIATION") %>', '<%# (Eval("UNIT_SYMBOL").ToString()=="K" ? "Kg" : (Eval("UNIT_SYMBOL").ToString() == "U" ? "Pc" : Eval("UNIT_SYMBOL"))) %>', '<%# Eval("PRODUCT_ID") %>', '<%# Telepaty.SecurityHelper.StringEncryptorDecryptor.Instance.EncryptString(Eval("PRODUCT_ID").ToString()) %>');return false;"
class="Clickable fleft" />
<% if (LoggedClient.Current != null)
{ %>
<img src="../images/Orders/BuyNow.png" alt="Buy Now" style="padding-left: 30px;"
height="23" onclick="javascript:window.location='Checkout.aspx?pID=<%# Telepaty.SecurityHelper.StringEncryptorDecryptor.Instance.EncryptString(Eval("PRODUCT_ID").ToString()) %>';return false;"
class="Clickable fright" />
<% }
else
{ %>
<img src="../images/Orders/BuyNow.png" alt="Buy Now" style="padding-left: 30px;"
height="23" onclick="javascript:window.location='/Login.aspx?ref=anonym&pID=<%# Telepaty.SecurityHelper.StringEncryptorDecryptor.Instance.EncryptString(Eval("PRODUCT_ID").ToString()) %>';return false;"
class="Clickable fright" />
<% }; %>
</td>
</tr>
</table>
</div>
</div>
</div>
</ItemTemplate>
</telerik:RadListView>
server side :
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
RadListView1.DataSource = OrderDataHelper.GetProductByCategoryforGrouping();
RadListView1.DataBind();
}
}
The RadListView control does not have an item placeholder specified
anyone know why this problem occured ?
You set ItemPlaceholderID="ProductsHolder" in your ListView but there is no PlaceHolder with given ID in your LayoutTemplate .
Just add this code to your LayoutTemplate
<LayoutTemplate>
<asp:PlaceHolder ID="ProductsHolder" runat="server"></asp:PlaceHolder>
</LayoutTemplate>
The error you are getting does means that you should declare a control in your LayoutTemplate which to determine where the items (ItemTemplate, EditItemTemplate etc.) should be instantiated.
Please refer to this live demo for a sample of how to construct RadListView programmatically.
I am using RequiredFieldValidator in my asp.net program. I have a sign out button which is used to terminate the session, but when i click on this sign out button without inserting any values in any of the text box the RequiredFieldValidator throws an error and i am not able to sign out.
I want to sign out a user without inputting any of the values in the textbox.
Please check my code in case of any problem in my code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class EntryForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{// CHEK SESSION VARIABLE AND LOAD dropdownlist1 WITH VALUES
if (!IsPostBack)
{
String DB = "";
String AccountID = "";
if (Session["login"] != null && Session["db"] != null)
{
AccountID = Session["login"].ToString();
DB = Session["db"].ToString();
Label9.Text = AccountID;
}
else
{
Response.Redirect("log.aspx");
}
HiddenField1.Value = DB.ToString();
DropDown a = new DropDown();
a.filldropdown1(this.DropDownList1, DB);
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
// LOG OUT***********////////////
Session.Abandon();
Response.Redirect("log.aspx");
}
.aspx code
<%# Page Language="C#" AutoEventWireup="true" CodeFile="EntryForm.aspx.cs" Inherits="EntryForm" %>
<%# Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit.HTMLEditor" tagprefix="cc1" %>
<!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>
<style type="text/css">
.style1
{
width: 330px;
}
.style2
{
text-align: center;
}
.style3
{
text-align: center;
width: 38px;
}
.style4
{
text-align: center;
width: 109%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width:90%; height: 30px;">
<tr>
<td class="style1">
<asp:Label ID="Label8" runat="server" style="text-align: left"
Text="Welcome"></asp:Label>
<asp:Label ID="Label9" runat="server" style="text-align: left"></asp:Label>
</td>
<td align="center" width="100%" style="text-align: right">
<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click"
style="text-align: right">Log Out</asp:LinkButton>
</td>
</tr>
</table>
</div>
<table style="width:95%;" align="center" bgcolor="Silver">
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Type : "></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server"
ControlToValidate="DropDownList1" ErrorMessage="*"
InitialValue="<-- Select -->">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="Label2" runat="server" Text="No. :"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Width="75px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="*">*</asp:RequiredFieldValidator>
</td>
<td>
<asp:Label ID="Label3" runat="server" Text="Year :"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" Width="75px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="TextBox2" ErrorMessage="Enter Year">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="TextBox2" ErrorMessage="Enter year"
ValidationExpression="^\d{4}$">YYYY</asp:RegularExpressionValidator>
</td>
<td>
<asp:Label ID="Label4" runat="server" Text="Order Date : "></asp:Label>
<asp:TextBox ID="TextBox3" runat="server" Width="75px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ControlToValidate="TextBox3" ErrorMessage="Enter proper format">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
ControlToValidate="TextBox3" ErrorMessage="Enter valid date"
ValidationExpression="^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((19|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((19|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((19|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$">dd/mm/yyyy</asp:RegularExpressionValidator>
</td>
<td>
<asp:Button ID="Button2" runat="server" Text="GO" onclick="Button2_Click" />
</td>
</tr>
</table>
<br />
<table style="width:100%;">
<tr>
<td style="text-align: center">
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True"
style="text-align: center" Visible="False"
onselectedindexchanged="DropDownList2_SelectedIndexChanged">
</asp:DropDownList>
</td>
</tr>
</table>
<br />
<table style="width:100%;">
<tr>
<td style="text-align: center" width="100%">
<asp:Label ID="Label5" runat="server" Text="Label" Visible="False"
style="text-align: center"></asp:Label>
</td>
<td style="text-align: center" width="100%">
<asp:Label ID="Label6" runat="server" Text="Vs" Visible="False"></asp:Label>
</td>
<td style="text-align: center" width="100%">
<asp:Label ID="Label7" runat="server" Text="Label" Visible="False"></asp:Label>
</td>
</tr>
</table>
<br />
<table style="width:100%;" border="1">
<tr>
<td class="style3" width="100%">
</td>
<td class="style4" width="100%">
<cc1:Editor ID="Editor1" runat="server" Width="60%" AutoFocus="true"
style="text-align: right" />
</td>
<td class="style2" width="100%">
</td>
</tr>
</table>
<br />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:HiddenField ID="HiddenField1" runat="server"/>
</form>
</body>
</html>
There are 2 ways you can do this
put validation group property to your controls
ValidationGroup="input"
OR
On your sign out link button, put
CausesValidation="false"
Use validation group property to group the items to be validated.
http://www.w3schools.com/ASPNET/prop_webcontrol_imagebutton_validationgroup.asp
On your Sign Out button set CausesValidation property to false
<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click"
CausesValidation="False"
style="text-align: right">Log Out</asp:LinkButton>
There is a property of button CausesValidation; set it to false. Than the validations on page won't fire.