I have two RadListBoxes, i.e radListBoxSource and RadListBoxDestination.
Here I am binding radListBoxSource items with DataSource and transfer to RadListBoxDestination.
Now I want to add some text from TextBox to RadListBoxDestination which data is not in radListBoxSource.
For this I added TextBox and Button.
Please tell me how to bind TextBox data and radListBoxSource data to RadListBoxDestination.
.aspx:
<telerik:RadListBox runat="server" ID="radListBoxSource" Height="350px" Width="250px"
EnableDragAndDrop="true" TransferMode="Move" SelectionMode="Multiple" AllowTransfer="true"
TransferToID="RadListBoxDestination" AutoPostBackOnTransfer="true" DataSortField="CandidateColumn"
DataKeyField="ColumnID" AllowReorder="true">
<EmptyMessageTemplate>
No columns exist
</EmptyMessageTemplate>
<HeaderTemplate>
<table width="100%">
<tr>
<td style="font-weight: bold; text-align: left;">
Candidate Columns
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<div style="width: 100%;">
<%# Eval("CandidateColumn") %>
</div>
</ItemTemplate>
</telerik:RadListBox>
<telerik:RadListBox ID="RadListBoxDestination" Height="350px" Width="250px" runat="server"
SelectionMode="Multiple" EnableDragAndDrop="true" AllowReorder="true">
<EmptyMessageTemplate>
No columns exist
</EmptyMessageTemplate>
<HeaderTemplate>
<table width="100%">
<tr>
<td style="font-weight: bold; text-align: left;">
Candidate Columns
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<div style="width: 100%;">
<%# Eval("CandidateColumn") %>
</div>
</ItemTemplate>
</telerik:RadListBox>
<table>
<tr>
<td>
<asp:Label ID="lblText" runat="server" Text="Enter Custom Field Name" Font-Bold="true"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtFieldName" runat="server" Width="175px"></asp:TextBox>
</td>
<td>
<asp:Button ID="btnAdd" CssClass="form_btn_txt" runat="server" Text="Add" OnClick="btnAdd_Click" />
</td>
</tr>
</table>
.cs:
protected void btnAdd_Click(object sender, EventArgs e)
{
RadListBoxItem test1 = new RadListBoxItem("item 1");
test1.Text = txtFieldName.Text.Trim();
RadListBoxDestination.Items.Insert(test1.Clone());
}
And I am binding radListBoxSource as follows:
private void FillComboData()
{
BizCandidate bizCandidates = new BizCandidate();
DataSet dsCandidates = new DataSet();
try
{
dsCandidates = bizCandidates.GetCandidateColumns();
if (dsCandidates != null && dsCandidates.Tables.Count > 0)
{
if (dsCandidates.Tables[0].Rows.Count > 0)
{
radListBoxSource.DataSource = dsCandidates.Tables[0];
radListBoxSource.DataValueField = "ColumnID";
radListBoxSource.DataTextField = "CandidateColumn";
radListBoxSource.DataBind();
}
}
}
catch { }
}
Remove the itemTemplate from the RadListBoxDestination, as you are not using a data source for this list box:
<telerik:RadListBox ID="RadListBoxDestination" Height="350px" Width="250px" runat="server"
SelectionMode="Multiple" EnableDragAndDrop="true" AllowReorder="true">
<EmptyMessageTemplate>
No columns exist
</EmptyMessageTemplate>
<HeaderTemplate>
<table width="100%">
<tr>
<td style="font-weight: bold; text-align: left;">
Candidate Columns
</td>
</tr>
</table>
</HeaderTemplate>
</telerik:RadListBox>
Related
I have a listview that I bind using custom code in the code behind. The listview has a datapager and needs to be sorted.
I created a custom sort routine that successfully sorts the list view. The issue is that if I change the page using the datapager, the sort is not maintained (i.e. page 2 and up are not sorted)
Here is the code for the list view:
<asp:ListView ID="lv_positions_i_posted" runat="server" DataKeyNames="postingid" OnPagePropertiesChanging="lv_positions_i_posted_paging" OnItemDataBound="lv_positions_i_posted_ItemDataBound">
<LayoutTemplate>
<table id="Table2" runat="server">
<tr id="Tr1" runat="server">
<td id="Td1" runat="server">
<table id="itemPlaceholderContainer" runat="server" border="1"
style="border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px; font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr>
<th colspan="2" style="background-color: darkseagreen;">Posting </th>
<th colspan="1" style="background-color: sandybrown;">Applications </th>
<th colspan="4">Positions I Posted </th>
</tr>
<tr id="Tr2" runat="server" style="color: #000000;">
<th id="Th1" runat="server" style="background-color: darkseagreen;">View </th>
<th id="Th2" runat="server" style="background-color: darkseagreen;">Edit </th>
<th id="Th3" runat="server" style="background-color: sandybrown;">View </th>
<th id="Th4" runat="server">ID </th>
<th id="Th6" runat="server">Title </th>
<th id="Th8" runat="server">Posting Date
<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="conditional">
<ContentTemplate>
<asp:ImageButton ID="SortPostingButton" runat="server" ImageUrl="~/images/Up2.png" Height="20px" Width="20px" ToolTip="Sort" OnClick="PostingSort1_Click" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="SortPostingButton" />
</Triggers>
</asp:UpdatePanel>
</th>
<th id="Th9" runat="server">Status
<asp:ImageButton ID="SortStatusButton" runat="server" ImageUrl="~/images/Up2.png" Height="20px" Width="20px" ToolTip="Sort" OnClick="StatusSort1_Click" />
</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr id="Tr3" runat="server">
<td id="Td2" runat="server"
style="text-align: center; background-color: #CCCCCC; font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000;">
<asp:DataPager ID="DataPager1" runat="server" PagedControlID="lv_positions_i_posted" PageSize="20">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
ShowNextPageButton="False" ShowPreviousPageButton="False" />
<asp:NumericPagerField ButtonCount="10" />
<asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True"
ShowNextPageButton="False" ShowPreviousPageButton="False" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr style="background-color: #DCDCDC; color: #000000; font-weight: normal;">
<td style="text-align: center">
<asp:ImageButton ID="ViewPostingButton" runat="server" ToolTip="View Posting" ImageUrl="~/images/green-eye-icon-new-small.png" Width="30px" Height="18.75px" OnCommand="ViewPostingButton_Click" CommandArgument=' <%#Eval("PostingID")%>' />
</td>
<td style="text-align: center">
<asp:ImageButton ID="EditPostingButton" runat="server" ToolTip="Edit Posting" ImageUrl="~/images/pencil_small.png" Width="18.75px" Height="18.75px" OnCommand="EditPostingButton_Click" CommandArgument=' <%#Eval("PostingID")%>' />
</td>
<td style="text-align: center">
<asp:ImageButton ID="ViewPostingApplicantButton" runat="server" ToolTip="View Applicants" ImageUrl="~/images/green-eye-icon-new-small.png" Width="30px" Height="18.75px" ImageAlign="Middle" OnCommand="ViewPostingApplicantButton_Click" CommandArgument=' <%#Eval("PostingID")%>' />
</td>
<td style="text-align: center">
<asp:Label ID="PostingID" runat="server" Text=' <%# Eval("PostingID") %>' Visible="true" />
</td>
<td>
<asp:Label ID="PostingTitle" runat="server" Text=' <%# Eval("PostingTitle") %>' Visible="true" ToolTip=' <%# Eval("PostingTitleFull") %>' />
</td>
<td style="text-align: center">
<asp:Label ID="PostingDate" runat="server" Text=' <%# Eval("PostingDate","{0:MM/dd/yyyy}") %>' Visible="true" />
</td>
<td style="text-align: center">
<asp:Label ID="PostingStatusID" runat="server" Text=' <%# Eval("PostingStatusID") %>' Visible="true" />
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="background-color: #FFF8DC; color: #000000; font-weight: normal;">
<td style="text-align: center">
<asp:ImageButton ID="ViewPostingButton" runat="server" ToolTip="View Posting" ImageUrl="~/images/green-eye-icon-new-small.png" Width="30px" Height="18.75px" OnCommand="ViewPostingButton_Click" CommandArgument=' <%#Eval("PostingID")%>' />
</td>
<td style="text-align: center">
<asp:ImageButton ID="EditPostingButton" runat="server" ToolTip="Edit Posting" ImageUrl="~/images/pencil_small.png" Width="18.75px" Height="18.75px" OnCommand="EditPostingButton_Click" CommandArgument=' <%#Eval("PostingID")%>' />
</td>
<td style="text-align: center">
<asp:ImageButton ID="ViewPostingApplicantButton" ToolTip="View Applicants" runat="server" ImageUrl="~/images/green-eye-icon-new-small.png" Width="30px" Height="18.75px" ImageAlign="Middle" OnCommand="ViewPostingApplicantButton_Click" CommandArgument=' <%#Eval("PostingID")%>' />
</td>
<td style="text-align: center">
<asp:Label ID="PostingID" runat="server" Text=' <%# Eval("PostingID") %>' Visible="true" />
</td>
<td>
<asp:Label ID="PostingTitle" runat="server" Text=' <%# Eval("PostingTitle") %>' Visible="true" ToolTip=' <%# Eval("PostingTitleFull") %>' />
</td>
<td style="text-align: center">
<asp:Label ID="PostingDate" runat="server" Text=' <%# Eval("PostingDate","{0:MM/dd/yyyy}") %>' Visible="true" />
</td>
<td style="text-align: center">
<asp:Label ID="PostingStatusID" runat="server" Text=' <%# Eval("PostingStatusID") %>' Visible="true" />
</td>
</tr>
</AlternatingItemTemplate>
<EmptyDataTemplate>
<table id="Table1" runat="server"
style="background-color: #FFFFFF; border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px;">
<tr>
<td>No data was returned. </td>
</tr>
</table>
</EmptyDataTemplate>
</asp:ListView>
Here is where I capture the sort:
protected void PostingSort1_Click(object sender, ImageClickEventArgs e)
{
if (TheListView.Text == "1")
{
if (LastSortField.Text == "p.postingdate")
{
if (LastSortDirection.Text == "asc")
{
ImageButton button = (ImageButton)sender;
button.ImageUrl = "~/images/Down2.png";
}
else
{
ImageButton button = (ImageButton)sender;
button.ImageUrl = "~/images/Up2.png";
}
}
}
currentLV = TheListView.Text;
BindListview(currentLV, "p.postingdate");
}
Here is where I bind/re-bind the listview:
protected void BindListview(string selectedItem, string orderby)
{
string SQL = "";
string direction = "";
SQL = "Select Statment Here";
if (orderby != "")
{
if (selectedItem == TheListView.Text)
{
if (orderby == LastSortField.Text)
{
if (LastSortDirection.Text == "asc")
{
direction = "desc";
}
else
{
direction = "asc";
}
SQL += " Order by " + orderby + " " + direction;
LastSortDirection.Text = direction;
LastSortField.Text = orderby;
}
else
{
SQL += " Order by " + orderby;
LastSortDirection.Text = "asc";
LastSortField.Text = orderby;
}
}
else
{
SQL += " Order by '" + orderby ;
LastSortDirection.Text = "asc";
LastSortField.Text = orderby;
}
}
else
{
SQL += " Order by PostingID asc";
LastSortDirection.Text = "asc";
LastSortField.Text = "PostingID";
}
DataSet ds = jdh.GetDataSetFromDB(SQL);
lv_positions_i_posted.DataSource = ds;
lv_positions_i_posted.DataBind();
lv_positions_i_posted.Visible = true;
ds.Dispose();
}
As I indicated, the displayed listview data is sorted correctly EXCEPT it is not being maintained when I use the datapager. I am expecting that the entire listview is sorted correctly throughout the paged data.
I figured it out. I forgot that I captured the datapager page change and was not passing in the "orderby" variable. Once I fixed that it works correctly.
protected void lv_positions_i_manage_paging(object sender, PagePropertiesChangingEventArgs e)
{
(lv_positions_i_manage.FindControl("DataPager1") as DataPager).SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
if (LastSortDirection.Text == "asc")
{
LastSortDirection.Text = "desc";
}
else
{
LastSortDirection.Text = "asc";
}
BindListview("2", LastSortField.Text);
}
There is a ListView which shows the data that were retrieved from the database.
I want to edit a single record on a ListView by clicking the edit button beside it but if I press the edit button, I get the error:
The ListView 'lvItemView' raised event ItemEditing which wasn't handled.
Here is the ListView:
<asp:ListView ID="lvItemView" runat="server" ItemPlaceholderID="itemHolder">
<LayoutTemplate>
<table style="color: Black;" width="100%" border="0" cellpadding="5">
<tr>
<th style="text-align: center;">Customer ID</th>
<th style="text-align: center;">Contact Name</th>
<th style="text-align: center;">Company</th>
<th style="text-align: center;">Created By</th>
<th style="text-align: center;">Created Date</th>
<th style="text-align: center;">Modified By</th>
<th style="text-align: center;">Modified Date</th>
</tr>
<asp:PlaceHolder ID="itemHolder" runat="server"></asp:PlaceHolder>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td align="left">
<asp:Label ID="lblCustomerID" runat="Server" Text='<%#Eval("_CustomerID") %>' />
</td>
<td align="left">
<asp:Label ID="lblContactName" runat="Server" Text='<%#Eval("_ContactName") %>' />
</td>
<td align="left">
<asp:Label ID="lblCompany" runat="Server" Text='<%#Eval("_CompanyID") %>' />
</td>
<td align="left">
<asp:Label ID="lblCreatedBy" runat="Server" Text='<%#Eval("_CreatedBy") %>' />
</td>
<td align="left">
<asp:Label ID="lblCreatedDate" runat="Server" Text='<%#Eval("_CreatedDate") %>' />
</td>
<td align="left">
<asp:Label ID="lblModifiedBy" runat="Server" Text='<%#Eval("_ModifiedBy") %>' />
</td>
<td align="left">
<asp:Label ID="lblModifiedDate" runat="Server" Text='<%#Eval("_ModifiedDate") %>' />
</td>
<td align="left">
<asp:LinkButton ID="EditButton" runat="Server" Text="Edit" CommandName="Edit" CommandArgument='<%#DataBinder.Eval(Container, "DataItemIndex")%>' />
</td>
<td align="left">
<asp:LinkButton ID="Delete" runat="Server" Text="Delete" CommandName="Delete" CommandArgument='<%#DataBinder.Eval(Container, "DataItemIndex")%>' />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
And the code behind
protected void lvItemView_ItemEditing(object sender, ListViewEditEventArgs e)
{
System.Web.UI.WebControls.Label index_id = (System.Web.UI.WebControls.Label)lvItemView.Items[e.NewEditIndex].FindControl("lblCustomerID");
int customerID = int.Parse(index_id.Text);
Item item = new Item();
item._CustomerID = customerID;
System.Web.UI.WebControls.Label cmp_id = (System.Web.UI.WebControls.Label)lvItemView.Items[e.NewEditIndex].FindControl("lblCompany");
int companyID = int.Parse(cmp_id.Text);
item._CompanyID = companyID;
System.Web.UI.WebControls.Label samp = (System.Web.UI.WebControls.Label)lvItemView.Items[e.NewEditIndex].FindControl("lblContactName");
item._ContactName = samp.Text;
samp = (System.Web.UI.WebControls.Label)lvItemView.Items[e.NewEditIndex].FindControl("lblCreatedBy");
item._CreatedBy = samp.Text;
samp = (System.Web.UI.WebControls.Label)lvItemView.Items[e.NewEditIndex].FindControl("lblCreatedDate");
item._CreatedDate = samp.Text;
samp = (System.Web.UI.WebControls.Label)lvItemView.Items[e.NewEditIndex].FindControl("lblModifiedBy");
item._ModifiedBy = samp.Text;
samp = (System.Web.UI.WebControls.Label)lvItemView.Items[e.NewEditIndex].FindControl("lblModifiedDate");
item._ModifiedDate = samp.Text;
CustomerID = item._CustomerID.ToString();
ContactName = item._ContactName.ToString();
CompanyID = item._CompanyID.ToString();
CreatedBy = item._CreatedBy.ToString();
CreatedDate = item._CreatedDate.ToString();
ModifiedBy = item._ModifiedBy.ToString();
ModifiedDate = item._ModifiedDate.ToString();
modAdd.Show();
}
I am new to asp.net and c# so I have no idea what to do with this kind of error.
set the event lvItemView_ItemEditing in OnItemEditing which will be triggered when click on edit button
<asp:ListView ID="lvItemView" runat="server" ItemPlaceholderID="itemHolder" OnItemEditing="lvItemView_ItemEditing">
and also set data source if you are binding on pageload
lvItemView.DataSource = SomeData;
lvItemView.DataBind();
Hello I have following aspx code and when the button inside ItemTemplate is cliked i need to pass the Item.BookID into code behind and I am unsure how to do it as there can be multiple items in the view. Thank you help would be much appreciated.
<asp:ListView runat="server" ID="UserDetailBooks" DefaultMode="ReadOnly" ItemType="WebApplication1.Models.Borrowed" SelectMethod="GetBorrow" DeleteMethod="ReturnBook">
<EmptyDataTemplate>
<h3>No borrowed books!</h3>
</EmptyDataTemplate>
<LayoutTemplate>
<div style="margin-left: auto; margin-right: auto; width: 50%;">
<h4>Books in possesion:</h4>
<table style="border-spacing: 2px;">
<tr id="groupPlaceholder" runat="server">
</tr>
</table>
</div>
</LayoutTemplate>
<GroupTemplate>
<tr>
<td id="itemPlaceholder" runat="server"></td>
</tr>
</GroupTemplate>
<ItemTemplate>
<td><asp:Button runat="server" Text="Return" OnClick="ReturnBook" />
<%#:Item.BookTitle %>
</td>
</ItemTemplate>
</asp:ListView>
You could pass the id in the button attributes?
<asp:Button runat="server" Text="Return" BookID="<%#:Item.BookID %>" OnClick="ReturnBook" />
<%#:Item.BookTitle %>
void ReturnBook(object sender, EventArgs e) {
Button b = sender;
string BookId = b.Attributes["BookID"];
}
Hi I am building an online sports goods shop,
I have this plan of loading in all Sports Type in the Home page, like Football,Cricket,Basketball etc
And the administrator can create a game at his own will,
Here's the confusion
How do I display the SubCategories of each Game if clicked (inside the repeater).
I thought of adding an ImageButton to it!! But then how do I link that Image Button to the games, i.e. when the user clicks the respective Image button -> The subcategories of that game should be displayed
For example:
1. If I have games such as Cricket,Football etc.
2. The Repeater should show all the games in the repeater
3. When The User clicks on for instance Cricket
4. I wish to load all subcategories of cricket goods such as the BAT,BALL,STUMPS etc.
I attempted this by loading the games in Repeater as shown in below code snippet:
<asp:Repeater ID="RepDetails" runat="server"
ondatabinding="RepDetails_DataBinding">
<HeaderTemplate>
<table style="border: 1px solid #df5015; width: 500px" cellpadding="0">
<tr style="background-color: #df5015; color: White">
<td colspan="2">
<b>Type of Sports</b>
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="background-color: #EBEFF0">
<td>
<table style="background-color: #EBEFF0; border-top: 1px dotted #df5015; width: 500px">
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("Id") %>' />
</td>
<td>
<asp:Label ID="lblSubject" runat="server" Text='<%#Eval("Category") %>' Font-Bold="true" />
</td>
<td>
<asp:ImageButton ID="ImageButton1" runat="server" OnClick="ImageButton2_Click" />
</td>
</tr>
</table>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
I've even added the ImageButton but confused about making it load the respective subcategories of that game!
Suggestions are welcome if there can be another work around which can be more effective..
You could try a nested repeater
In aspx
<asp:Repeater ID="RepDetails" runat="server" OnDataBinding="RepDetails_DataBinding">
<HeaderTemplate>
<table style="border: 1px solid #df5015; width: 500px" cellpadding="0">
<tr style="background-color: #df5015; color: White">
<td colspan="2">
<b>Type of Sports</b>
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="background-color: #EBEFF0">
<td>
<table style="background-color: #EBEFF0; border-top: 1px dotted #df5015; width: 500px">
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("Id") %>' />
</td>
<td>
<asp:Label ID="lblSubject" runat="server" Text='<%#Eval("Category") %>' Font-Bold="true" />
</td>
<td>
<asp:ImageButton ID="ImageButton1" runat="server" OnClick="ImageButton2_Click" />
</td>
</tr>
</table>
</td>
</tr>
<asp:Repeater ID="SportsProps" runat="server">
<ItemTemplate>
<tr style="background-color: #EBEFF0">
<td>
<table style="background-color: #EBEFF0; border-top: 1px dotted #df5015; width: 500px">
<tr>
<td>
<asp:Label ID="lblSubject" runat="server" Text='<%#Eval("Name") %>' Font-Bold="true" />
</td>
<td>
<asp:ImageButton ID="ImageButton3" runat="server" OnClick="ImageButton3_Click" />
</td>
</tr>
</table>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
In code behind
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
RepDetails.DataSource = GetData();
RepDetails.DataBind();
}
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
Repeater repeater = ((ImageButton)sender).NamingContainer.FindControl("SportsProps") as Repeater;
Label catLabel = ((ImageButton)sender).NamingContainer.FindControl("lblSubject") as Label;
repeater.DataSource = GetDataDetail(catLabel.Text);
repeater.DataBind();
}
protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
{
//do something to hide the
}
private DataTable GetData()
{
DataTable dt = new DataTable();
dt.Columns.Add("id", typeof(string));
dt.Columns.Add("category", typeof(string));
dt.Rows.Add("1 ", "Basketball");
dt.Rows.Add("2 ", "Football");
dt.Rows.Add("3 ", "Soccer");
return dt;
}
private DataTable GetDataDetail(string category)
{
DataTable dt = new DataTable();
dt.Columns.Add("name", typeof(string));
dt.Rows.Add("Bat");
dt.Rows.Add("Ball");
dt.Rows.Add("Stump");
return dt;
}
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