Reputation: 1484
I'm trying to figure out why my listview isn't displayed when I build my solution but it is displayed in visual studio. Am I missing some syntax in the HTML? When I examine the code using Firebug, there isn't any code showing it tried to render the listview.
ASPX Page:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm4.aspx.vb" Inherits="WebApplication2.WebForm4"
MasterPageFile="obj/Site1.Master" ViewStateMode="Enabled" %>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="ContentArea">
<fieldset>
<fieldset>
<legend style="text-align: center">Vendor Results Screen</legend>
<table width="100%">
<tr>
<td align="center">
<asp:Label ID="FilterBy" runat="server" Text="Filter By: " Font-Bold="true" Font-Size="Large"></asp:Label>
<asp:DropDownList ID="dropDownFieldName" runat="server">
<asp:ListItem Text="FieldName" Value="DocumentProviderID"> </asp:ListItem>
<asp:ListItem Text="Status" Value="Status"></asp:ListItem>
<asp:ListItem Text="FieldName" Value="PDFNumber"> </asp:ListItem>
</asp:DropDownList>
<br />
</td>
</tr>
<tr>
<td align="center" style="height: 34px">
<asp:Label ID="SearchBy" runat="server" Text="Search By: " Font-Bold="true" Font-Size="Large"></asp:Label>
<asp:TextBox ID="searchBox" runat="server"></asp:TextBox>
<asp:Button ID="SearchButton" runat="server" Text="Search" />
</td>
</tr>
<tr>
<td>
<table width="100%">
<tr>
<td>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true">
<asp:ListItem Value="10">10</asp:ListItem>
<asp:ListItem Value="25">25</asp:ListItem>
<asp:ListItem Value="50" Selected="True">50</asp:ListItem>
<asp:ListItem Value="75">75</asp:ListItem>
<asp:ListItem Value="100">100</asp:ListItem>
</asp:DropDownList>
</td>
<td align="right">
<asp:Button ID="ExportToExcel" runat="server" Text="Export To Excel" />
</td>
</tr>
</table>
</td>
</tr>
<asp:ListView ID="ListView1" runat="server" EnableViewState = "true" Visible="true">
<LayoutTemplate>
<table cellpadding="2" width="100%" border="1" runat="server" id="tblProducts">
<tr id="Tr1" runat="server">
<th id="Th1" runat="server">
Field Name
</th>
<th id="Th2" runat="server">
Type
</th>
<th id="Th3" runat="server">
XML Path
</th>
<th id="Th4" runat="server">
Vendor Path
</th>
<th id="Th5" runat="server">
Status
</th>
<th id="Th6" runat="server">
Comments
</th>
<th id="Th7" runat="server">
Edit
</th>
<th id="Th8" runat="server">
Forms
</th>
<th id="Th9" runat="server">
CU Specific
</th>
</tr>
<tr runat="server" id="itemPlaceholder" />
</table>
<asp:DataPager runat="server" ID="DataPager1" PageSize="50">
<Fields>
<asp:NumericPagerField ButtonCount="10" CurrentPageLabelCssClass="CurrentPage" NumericButtonCssClass="PageNumbers"
NextPreviousButtonCssClass="PageNumbers" NextPageText=" Next " PreviousPageText=" Previous " />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr id="Tr2" runat="server">
<td>
<asp:Label ID="FieldName" runat="Server" Text='<%#Eval("FLD_NM") %>' />
</td>
<td>
<asp:Label ID="Type" runat="Server" Text='<%#Eval("DATA_TYPE_CD") %>' />
</td>
<td>
<asp:Label ID="XMLPath" runat="Server" Text='<%#Eval("WS_XML_PATH_TX") %>' />
</td>
<td>
<asp:Label ID="VendorPath" runat="Server" Text='<%#Eval("FLD_NM") %>' />
</td>
<td>
<asp:DropDownList ID="Status" runat="Server" />
</td>
<td>
<asp:TextBox ID="Comments" runat="Server" MaxLength="100" />
</td>
<td>
<asp:LinkButton ID="EditButton" runat="Server" Text="Edit" CommandName="Edit" />
</td>
<td>
<asp:Label ID="Forms" runat="Server" Text='<%#Eval("FLD_NM") %>' />
</td>
<td>
<asp:Label ID="CUSpecific" runat="Server" Text='<%#Eval("FLD_NM") %>' />
</td>
</tr>
</ItemTemplate>
<EditItemTemplate>
<tr style="background-color: #ADD8E6">
<td>
<asp:LinkButton ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<asp:LinkButton ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:TextBox ID="FieldName" runat="server" Text='<%# Bind("FLD_NM") %>' MaxLength="50" /><br />
</td>
<td>
<asp:TextBox ID="DataType" runat="server" Text='<%# Bind("DATA_TYPE_CD") %>' MaxLength="50" /><br />
</td>
</tr>
</EditItemTemplate>
</asp:ListView>
</table>
</fieldset>
</fieldset>
</asp:Content>
VB:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Not IsPostBack) Then
dataTable()
Dim dataT As DataTable = dsData
dsData = ViewState("Table")
ListView1.DataSource = dataT.AsDataView
ListView1.DataBind()
'ListView1.Sort("FLD_NM", SortDirection.Descending)
dropDownFieldName.DataSource = dsData.Columns
dropDownFieldName.DataBind()
End If
End Sub
That's the VB I run, I do not believe the VB is the problem because I can put a breakpoint in and view the table. Also, my dropdownFieldName (I use for search) displays all the column headers I want. Let me know if I'm missing something obvious please!
Thank you, Greg
Upvotes: 1
Views: 2520
Reputation: 79
I'm not sure what datasource you're connecting to or if you're using an SQL query/SP. I was having trouble with this same problem, I found that my query parameters were passing different values to the stored proc before binding (which had nothing to do with the page rendering) when going from VS to IIS. The issue came when I was passing usernames.
If you think your data source may be to blame (which was my case) try inserting the following code on your page load and see the results:
Response.Write("Application code executed using: ");
Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name + "<br/>");
Response.Write("Is User Authenticated: ");
Response.Write(User.Identity.IsAuthenticated.ToString() + "<br/>");
Response.Write("Authentication Type, if Authenticated: ");
Response.Write(User.Identity.AuthenticationType + "<br/>");
Response.Write("Application code executed using: ");
Response.Write(User.Identity.Name + "<br/>");
Response.Write("Environment UserName: ");
Response.Write(Environment.UserName + "<br/>");
Then adjust your parameters as needed.
Hope this helps.
Upvotes: 0
Reputation: 3970
Your datasource for the listview is null. If the LisView datasource is null, then the server will not render the list view. I confirmed this by adding the following code server side into Page_Load:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Not IsPostBack) Then
Dim dt As New System.Data.DataTable
dt.Columns.Add(New System.Data.DataColumn("FLD_NM", GetType(System.Int32)))
dt.Columns.Add(New System.Data.DataColumn("DATA_TYPE_CD", GetType(System.String)))
dt.Columns.Add(New System.Data.DataColumn("WS_XML_PATH_TX", GetType(System.String)))
Dim row As System.Data.DataRow
row = dt.NewRow()
row.Item("FLD_NM") = 1
row.Item("DATA_TYPE_CD") = "A"
row.Item("WS_XML_PATH_TX") = "C:\TEMP\TEMP.XML"
dt.Rows.Add(row)
ListView1.DataSource = dt
ListView1.DataBind()
End If
End Sub
Upvotes: 1