www.webdeveloper.com
Results 1 to 4 of 4

Thread: DataList is Showing Up in Source Code, But Not On Web Page?

  1. #1
    Join Date
    May 2003
    Posts
    599

    Question DataList is Showing Up in Source Code, But Not On Web Page?

    For some reason, the data for my datalist is showing up in the source code of the page without a problem, but it's not being displayed on the webpage. That page is just blank. Why could this happen?

  2. #2
    Join Date
    May 2003
    Posts
    599
    Here are more details:

    I've tested all of the stored procedures on the web page and within SQL Server's Management Studio, and they work great. And as I stated, the data is appearing in the source code. Thanks.

    ASP.NET PAGE:
    Code:
       <form id="formEmployees" name="formEmployees" enctype="multipart/form-data" runat="server">
    		<div id="viewstatecontent">
    		<table width="100%" id="Employees">
    			<tbody>
    			<asp:DataList ID="dlEmployees" runat="server" OnItemDataBound="dtlEmployees_ItemDataBound" RepeatLayout="Flow">
    				<HeaderTemplate>
    					<tr>
    						<td>Full Name</td>
    					</tr>
    				</HeaderTemplate>
    				<ItemTemplate>
    					<tr>
    						<td>
    							<asp:Label ID="lblFullName" runat="server"></asp:Label>
    						</td>
    					</tr>
    				</ItemTemplate>
    			</asp:DataList>
    			</tbody>
    		</table>
    		</div>
    	</form>
    </asp:Content>
    VB.NET PAGE:
    Code:
    Partial Class employees
    	Inherits System.Web.UI.Page
    
    	'Assign global variables
    	Dim sqlConn As SqlConnection
    	Dim sqlCmd As SqlCommand
    	Dim strConnection As String
    	Public strJobID As String = Nothing
    	Private ds_details As New DataSet()
    	Private cmd_details As SqlDataAdapter = New SqlDataAdapter
    
    	Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
    		'Assign connection string
    		strConnection = System.Configuration.ConfigurationManager.AppSettings("strConn_Employees")
    		sqlConn = New SqlConnection(strConnection)
    		strJobID = Request.QueryString("JobID")
    
    		'Bind data
    		BindstrDbRecordID_employeedetails()
    	End Sub
    
    	'Bind Data to DataList Populating the Dataset
    	Sub BindstrDbRecordID_employeedetails()
    		'SELECT applications from database
    		cmd_details = New SqlDataAdapter("spEmployees @jobid = '" & strJobID & "'", sqlConn) 'LIVE
    
    		'Bind data
    		cmd_details.Fill(ds_details, "tblEmployees")
    		dlEmployees.DataSource = ds_details
    		dlEmployees.DataBind()
    
    	End Sub
    
    	'The ItemDataBound Event
    	Public Sub dtlEmployees_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs)
    
    		Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)
    
    		If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then
    			'Assign database values
    			Dim strDbFName As String = drv.Row("FName").ToString.Trim
    			Dim strDbMName As String = drv.Row("MName").ToString.Trim
    			Dim strDbLName As String = drv.Row("LName").ToString.Trim
    
    			'Assign label value
    			CType(e.Item.FindControl("lblFullName"), Label).Text = strDbLName & ", " & strDbMName & " " & strDbFName
    		End If
    		drv = Nothing 'Close DataRowView
    	End Sub
    End Class

  3. #3
    Join Date
    Oct 2009
    Posts
    658
    Quote Originally Posted by kwilliams View Post
    For some reason, the data for my datalist is showing up in the source code of the page without a problem, but it's not being displayed on the webpage. That page is just blank. Why could this happen?
    You lost me. You said its blank but its showing in the source code . Can you give us a link to see? You might also want to make sure you have value on your return set. Use log4net or some logging, debugging tools you're familiar with.

  4. #4
    Join Date
    May 2003
    Posts
    599

    resolved

    For security reasons, I couldn't post the entire set of code. But that page is located within a Master Page.

    So I just removed all of the Master Page code for testing, and the data appears. So it's obviously a problem with the Master Page.

    I appreciate your help!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles