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");
Related
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>
I make i my own mail interface system into my application and since the user click on Repsendbtn into listview called " viewmsgView " then he will hide the " viewmsgView" and show " repmsgform " and bind the data into repmsgform depending on mailno. What i am facing is as you all know that cant reach controls into listview or formview and the Repsendbtn is inside the formview and it will depend on others controls to process the below behind code but i am getting red-line under the controls id with message: " The name 'Label' does not exist in the current context " so how i can solve this case and make the button code work smoothly. Its may really not so clear my post, so i decide to make record screen which i hope will make it easily to explain what i am looking for. Please click on the below link and have a look of my screen record where i explain what i am looking for:
https://www.youtube.com/watch?v=OMKp7b6iMJ8&feature=youtu.be
<asp:FormView ID="repmsgform" runat="server" DataKeyNames="mailno" Width="100%" >
<ItemTemplate>
<div>
<table class="table table-bordered" style="margin-left:0px;" >
<tbody>
<tr>
<td style="border-collapse:collapse; border:2px solid white; color:#333333; background-color:#f0f0f0;">
Ads Number:
</td>
<td >
<asp:Label ID="adsnummsglbl" runat="server" Text='<%# Bind("AdsID") %>' ></asp:Label>
</td>
</tr>
<tr>
<td td style="border-collapse:collapse; border:2px solid white; color:#333333; background-color:#f0f0f0;">
Message Title:
</td>
<td>
<asp:Label ID="adstitmsglbl" runat="server" Color="#669900" Text='<%# Bind("Mestitle") %>'></asp:Label>
</td>
</tr>
<tr>
<td td style="border-collapse:collapse; border:2px solid white; color:#333333; background-color:#f0f0f0;">
From:
</td>
<td>
<asp:Label ID="Reciverlblnme" runat="server" Text='<%# Bind("Receiver") %>'></asp:Label>
</td>
</tr>
<tr>
<td style="border-collapse:collapse; border:2px solid white; color:#333333; background-color:#f0f0f0;">To:</td>
<td> <asp:Label ID="Tolbl" runat="server" Text='<%# Bind("sender") %>'></asp:Label></td>
</tr>
</tbody>
</table>
<div class="form-group">
<asp:Label ID="Label12" runat="server" Text="Label" CssClass="col-md-3 control-label">Your Message:</asp:Label>
<div class="col-md-9">
<asp:TextBox ID="TextBox1" runat="server" Height="150px" TextMode="multiline" CssClass="form-control"
></asp:TextBox>
</div>
</div>
<asp:Label ID="msgsentlbl" runat="server" Font-Size="Medium" ForeColor="#669900"></asp:Label>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="pull-right">
<asp:Button ID="Closebtn" runat="server" Text="Close"
CssClass="btn btn-default" onclick="Closebtn_Click"/>
<asp:Button runat="server" ID="Repsendbtn" Text="Send" CssClass="btn btn-primary"
onclick="Repsendbtn_Click"/></div>
</div></div>
</ItemTemplate>
</asp:FormView>
protected void Repsendbtn_Click(object sender, EventArgs e)
{
if (Session["UsrNme"] != null)
{
using (SqlConnection cn = new SqlConnection(sc))
{
string SendMsgSQL = #"INSERT mails [CVs] ([Message], [Mestitle], [AdsID], [Date], [Receiver], [sender])
VALUES (#Message, #Mestitle, #AdsID , #Date, #Receiver, #sender)";
using (SqlCommand SendMsgcmd = new SqlCommand(SendMsgSQL, cn))
{
cn.Open();
var user = Session["UsrNme"];
SendMsgcmd.Parameters.AddWithValue("#sender", user);
SendMsgcmd.Parameters.AddWithValue("#Message", TextBox1.Text);
SendMsgcmd.Parameters.AddWithValue("#Mestitle", adstitmsglbl.Text);
SendMsgcmd.Parameters.AddWithValue("#AdsID", adsnummsglbl.Text);
SendMsgcmd.Parameters.AddWithValue("#Date", DateTime.Now);
SendMsgcmd.Parameters.AddWithValue("#Receiver", Reciverlblnme.Text);
SendMsgcmd.ExecuteNonQuery();
Response.Redirect("User panel.aspx");
}
}
}
else
{
// Consider throwing an error (if these fields are required)
}
}
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.