Why my "<asp:ListView" isn't showing on the screen? - asp.net

This is part of my code that isn't working. I have looked for somethings, but i cannot search what my asp:ListView isn't showing, if someone knows about it, Help me !
<asp:ListView ItemPlaceholderID="PlaceHolder1" runat="server" ID="ListViewUser">
<LayoutTemplate>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"/>
<table id="Table1" class="TableListView" runat="server">
<tr id="Tr1" class="TableHeader" runat="server">
<td id="td1" runat="server">Nível</td>
<td id="td2" runat="server">Descrição</td>
<td id="td3" runat="server">Quantidade de Problema ?</td>
<td id="td4" runat="server">Selecionar</td>
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr class="ItemsCSS">
<td>
<asp:Label runat="server"
ID="Label1"
Text="Problema" >
</asp:Label>
</td>
<td>
<asp:Label runat="server"
ID="Label2"
Text="Problema" >
</asp:Label>
</td>
<td>
<asp:Label runat="server"
ID="Label3"
Text="Problema" >
</asp:Label>
</td>
</tr>
</ItemTemplate>
</asp:ListView>

Your ListView lacks bindings. You can add a DataSourceID property to the top level control and point to a DataSource control or programmatically bind to the DataSource property and then invoke DataBind(). But the control will not display anything without first binding it.

Related

Update panel with each row in repeater

I have repeater and when i put update panel in each row its still loading all other update panels is there any reason for this?
It should only update that part only that is i want to achieve.
<asp:Repeater runat="server" ID="grd" >
<HeaderTemplate>
<table class=" table-serviceline table table-hover table-bordered">
</HeaderTemplate>
<ItemTemplate>
<tr class="service-line-item" id="<%#"serviceline"+ Eval("ClaimServiceID") %>">
<td class="fw65">
<table class="table-small-pad">
<tr>
<td>
<asp:Label ID="lblID" ClientIDMode="Static" Text='<%#Container.ItemIndex+1 %>' runat="server"></asp:Label>
</td>
</tr>
</table>
</td>
<td class="fw150">
<table class="table-small-pad">
<tr>
<td>
<asp:UpdatePanel ID="upd" runat="server">
<ContentTemplate>
<div class="input-group">
<asp:TextBox ID="txtCODE" runat="server" CssClass="form-control" Text='<%# Bind("Code") %>' ToolTip="Code" MaxLength="15" />
<span class="input-group-addon"></span>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
I believe that the combo of
UpdateMode="Conditional"
and
ChildrenAsTriggers="True"
in the UpdatePanel is what you are looking for. If you don't set the first parameter, UpdatePanels update on any postback.

aspx repeater Do something with the data

I have made a webform, and by using a repeater i would like to display the results with the option of approving/disapproving applicants. I have searched high and low, but I am unable to discover how i can use the data of the item in the item repeater. If someone could point me in the right direction as to how i could do this i would appreciate it alot.
So as example. Someone presses the button approve in one of the repeated items. and i would like to do some db query using the email address which is displayed in that item
codebehind:
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if(((Button)e.CommandSource).Text.Equals("Approve"))
{
//
}
}
and this is the aspx:
<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
<ItemTemplate>
<div class="Application">
<table class="auto-style1">
<tr>
<td class="small">Application received:</td>
<td class="big"><asp:Label ID="lbl_App_Date" runat="server" Text='<%# Eval("app_date") %>'></asp:Label></td>
<td class="small">Status:</td>
<td class="small"><asp:Label ID="lbl_App_status" runat="server" Text='<%# Eval("app_status") %>'></asp:Label></td>
</tr>
<tr>
<td class="small">Email Address: </td>
<td class="big"><asp:Label ID="lbl_App_email" runat="server" Text='<%# Eval("app_email") %>'></asp:Label></td>
<td class="small">Age: </td>
<td class="small"><asp:Label ID="lbl_App_age" runat="server" Text='<%# Eval("app_age") %>'></asp:Label></td>
</tr>
<tr>
<td>Country: </td>
<td><asp:Label ID="lbl_App_Country" runat="server" Text='<%# Eval("app_country") %>'></asp:Label></td>
<td>Platform: </td>
<td><asp:Label ID="lbl_App_Platform" runat="server" Text='<%# Eval("app_platform") %>'></asp:Label></td>
</tr>
</table>
<p><b>Motivation to join: </b></p>
<asp:TextBox ID="txt_App_Moti" ReadOnly="true" Text='<%# Eval("app_moti") %>' TextMode="MultiLine" Height="150px" Width="60%" runat="server"></asp:TextBox>
<asp:Panel ID="pan_approval" runat="server">
<table class="auto-style1">
<tr>
<td class="small"></td>
<td class="big"><asp:Button ID="btn_approve" runat="server" Text="Approve" /></td>
<td class="small"></td>
<td class="small"><asp:Button ID="btn_disapprove" runat="server" Text="Disapprove" /></td>
</tr>
</table>
</asp:Panel>
</div>
</ItemTemplate>
</asp:Repeater>

ASP.Net CollapsiblePanelextender Control

Afternoon All,
I am wonding if i can configure and use a collapsiblePanelextender in ASP.net within a table. I would likt this to be used for a minutes of meeting system that i am creating. I have the following code and thought that if i added pnlPresenter and pnlTime to the CollapseControlID along with pnlHeader i would be able to get this to work but i cant.
Has anyone got any other suggestions?
<table width="100%">
<tr>
<td class="style3">Topic</td>
<td class="style2">Presenter</td>
<td>Time Alloted</td>
</tr>
<tr >
<td class="style1" colspan="3">
<asp:Panel ID="pnlHeader" runat="server" CssClass="cpHeader" Width="228%" Height="18px">
1. Agenda Item 1
<asp:Image ID="ImgToggle" runat="server" ImageUrl="~/Images/collapse.jpg" ImageAlign="Middle" />
</asp:Panel>
</td>
</tr>
<tr>
<td class="style3">
<asp:Panel ID="pnlInfo" runat="server" CssClass="cpBody" >
The Agenda topic details goes within here, The Agenda topic details goes within here,
The Agenda topic details goes within here, The Agenda topic details goes within here,.
</asp:Panel>
</td>
<td class="style2">
<asp:Panel ID="pnlPresenter" runat="server" CssClass="cpBody" Width="107px">
Presenters Name
</asp:Panel>
</td>
<td class="style2">
<asp:Panel ID="pnlTime" runat="server" CssClass="cpBody" Width="107px">
Time
</asp:Panel>
</td>
</tr>
</table>
Many Thanks in advance
Regards
Betty
It's not entirely clear what you want to achieve here, especially as there's no CollapsiblePanelExtender in the markup you've posted, so I'm writing this on the assumption that you want to display a page for a meeting where each agenda item is expandable/collapsible.
I suggest you build your table using a Repeater instead of hard-coding it into your page, then for each agenda item the Repeater can render a new row for you. Inside the row that's rendered by the Repeater, you can then have the agenda topic as a header, and the agenda item details as a panel that's expanded/collapsed using the extender:
<asp:Repeater runat="server" ID="AgendaRepeater" DataSourceID="AgendaDataSource">
<HeaderTemplate>
<table border="1">
<tr>
<td>
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label runat="server" ID="AgendaTopicLabel" Text='<%# Eval("Topic") %>' />
<asp:ImageButton runat="server" ID="PanelExpandContractImageButton" ImageUrl="~/images/zoom_in_16x16.gif" />
<asp:Panel runat="server" ID="AgendaItemDetailsPanel" Height="0px">
<asp:Label runat="server" ID="TopicDetailsLabel" Text='<%# Eval("Details") %>' /><br />
<asp:Label runat="server" ID="PresenterLabel" Text='<%# Eval("Presenter") %>' /><br />
<asp:Label runat="server" ID="TimeLabel" Text='<%# Eval("Time") %>' />
</asp:Panel>
<ajaxToolkit:CollapsiblePanelExtender runat="server" TargetControlID="AgendaItemDetailsPanel"
Collapsed="true" ExpandControlID="PanelExpandContractImageButton" CollapseControlID="PanelExpandContractImageButton"
ImageControlID="PanelExpandContractImageButton" CollapsedImage="~/images/zoom_in_16x16.gif"
ExpandedImage="~/images/zoom_out_16x16.gif" ExpandedSize="100" ExpandDirection="Vertical"
ScrollContents="true" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>

asp.net Update Panel capturing Button clicks

I have a page that has an ASP.NET UpdatePanel on it. The UpdatePanel contains a repeater, and within the repeater is a command button. (please see the code example below)
When I click on the button the first time, nothing happens. But the second time I click on the same button, then I get the event I was expecting triggered. I am at a loss as to why this is, though I am sure there is a simple explanation. Any advice would be helpful.
<!-- Drivers Table -->
<asp:UpdatePanel runat="server" ID="DriverUpdatePanel" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:HiddenField runat="server" ID="DriverErrors" />
<asp:Repeater ID="DriverRepeater" runat="server" OnItemDataBound="DriverRepeater_ItemDataBound" OnItemCommand="DriverRepeater_ItemCommand">
<HeaderTemplate>
<table cellspacing="0" class="section-table">
<tr>
<td class="bg_mid" colspan="7"><img src="/images/sections/drivers.png" alt="Drivers" /></td>
</tr>
<tr>
<td class="text_1 left-cell">#</td>
<td class="text_1">Name</td>
<td class="text_1">Date Of Birth</td>
<td class="text_1">Gender</td>
<td class="text_1">License #</td>
<td class="text_1">Relationship</td>
<td class="text_1" align="right"> </td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr id="DriverRow" runat="server">
<td class="text_2 required left-cell"><asp:Label ID="DriverNumber" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "DriverNumber")%>'></asp:Label></td>
<td class="text_2 required"><asp:Label ID="DriverName" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "FirstName")%>'></asp:Label></td>
<td class="text_2 required"><asp:Label ID="BirthDate" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "BirthDate")%>'></asp:Label></td>
<td class="text_2 required"><asp:Label ID="Gender" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Gender").ToString() == "F" ? "Female" : "Male" %>'></asp:Label></td>
<td class="text_2 required"><asp:Label ID="DriversLicenseNumber" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "LicenseInformation.DriversLicenseNumber")%>'></asp:Label></td>
<td class="text_2 required"><asp:Label ID="RelationshipToApplicant" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "RelationshipToApplicant")%>'></asp:Label></td>
<td class="text_2 right-cell" align="right"><asp:ImageButton runat="server" ID="DriverEditButton"
ImageUrl="/images/edit.jpg" AlternateText="Edit" CommandName="Edit" CausesValidation="false" /></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
make UpdatePanel Mode="Conditional" and enableviewstate="true"
you not need to defined trigger and you work is done without it.

How to set radio button Id property based on database value?

I have grid view which contains five radio buttons per row. Out of these five only one can be checked at a time. To achieve this I tried to keep Id property of radio button corresponding to database value. But it gives me an error in Id field. .Net does not allow to use eval function in ID property. The rows will depend on number of records in database. I want to keep 5 radio button in database and out of these five, only one can be checked. How to achieve this task?
//My code of .aspx page is as below.
<%# Page Title="Applicant Rating Form" Language="C#" MasterPageFile="~/Interviewer/interviewerMasterPage.master" AutoEventWireup="true" CodeFile="AppRatingForm.aspx.cs" Inherits="Interviewer_AppRatingForm" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table cellpadding="2" width="100%">
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td align="center" class="tdtitle" colspan="2">
Interview Rating Form</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td width="25%">
Name of Applicant</td>
<td>
<asp:Label ID="nameLbl" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td>
Post Applied For</td>
<td>
</td>
</tr>
<tr>
<td>
Department</td>
<td>
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td align="center" class="tdtitle" colspan="2">
Assessment</td>
</tr>
<tr>
<td align="left" colspan="2">
<asp:GridView ID="assesmentGrid" runat="server" AutoGenerateColumns="False"
onpageindexchanging="assesmentGrid_PageIndexChanging">
<Columns>
<asp:BoundField HeaderText="ID" DataField="SecId"/>
<asp:BoundField HeaderText="Traits" DataField="SecName"/>
<asp:TemplateField>
<HeaderTemplate>
A
</HeaderTemplate>
<ItemTemplate>
<asp:RadioButton ID='<%# Eval("SecId") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
B
</HeaderTemplate>
<ItemTemplate>
<asp:RadioButton ID='<%# Eval("SecId") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
C
</HeaderTemplate>
<ItemTemplate>
<asp:RadioButton ID='<%# Eval("SecId") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
D
</HeaderTemplate>
<ItemTemplate>
<asp:RadioButton ID='<%# Eval("SecId") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
E
</HeaderTemplate>
<ItemTemplate>
<asp:RadioButton ID='<%# Eval("SecId") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
Comments
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="commentBox" runat="server" TextMode="MultiLine"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
<tr>
<td align="center" class="tdtitle" colspan="2">
</td>
</tr>
<tr>
<td align="center" colspan="2">
</td>
</tr>
<tr>
<td align="center" colspan="2">
</td>
</tr>
</table>
</asp:Content>
You need to set the GroupName property of all RadioButtons in the same group/row. This will only allow one to be selected at a time. I wouldn't suggest trying to set the IDs dynamically using Eval, just make sure they are all unique and it should work fine.

Resources