 |
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

November 17th, 2009, 04:47 PM
|
Banned
|
|
Join Date: Jul 2005
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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?
|

November 17th, 2009, 05:00 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
- Fuzzy glasses?
- White text on a white background?
- display: none; on the * selector?
- Broken HTML
- Broken CSS?
- Some script that hides or shows stuff?
In other words: difficult to tell without seeing the actual HTML or, better yet, a live demo page....
Imar
|

November 17th, 2009, 05:29 PM
|
Banned
|
|
Join Date: Jul 2005
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
- Fuzzy glasses? Nope
- White text on a white background? Nope
- display: none; on the * selector? Nope
- Broken HTML Nope
- Broken CSS? Nope
- Some script that hides or shows stuff? Nope
That's what is strange. Below is the code, but I still don't get why it would show up in the source-code without being on the webpage. 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
|

November 17th, 2009, 05:57 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Quote:
And as I stated, the data is appearing in the source code.
|
If the data ends up correctly as HTML at the client, then it must be a client side issue. So, rather than posting the server side code, you're better off showing us the client code.
Does using the IE Dev Toolbar or Firebug tell you anything about the state of the page? What happens when you disable CSS and script?
Imar
|

November 17th, 2009, 06:05 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
BTW: Take a look at this:
Code:
<form id="formEmployees" name="formEmployees" enctype="multipart/form-data" runat="server">
...
</form>
</asp:Content>
This is odd. </asp:Content> implies the page is a Content Page and is using a MasterPage. However, in that case, <form /> shouldn't be in the content page, but in the master page. Doesn't your master page have a form? (You should get an error if you have two server-side forms).
Are you sure your page is set up and executing correctly?
Imar
|

November 17th, 2009, 06:10 PM
|
Banned
|
|
Join Date: Jul 2005
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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!
|

November 17th, 2009, 06:19 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
I don't think security reasons should prohibit you from posting relevant HTML, do they? I mean, you could simply post the HTML, remove all rows / data from the page except for one which you modify slightly and you should be good to go.
Anyway, glad it's solved now.
Imar
|

November 17th, 2009, 06:22 PM
|
Banned
|
|
Join Date: Jul 2005
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Honestly, for me to copy and paste the entire set of code, including stored procedures, and then go through every item to remove anything that has actual table names, datalist names, etc is extremely difficult to do. When I've done it in the past, I've received feedback that it was in-fact too much data, and they wanted to get to the meat of the problem. I guess you can never really win when it comes to posting code.
Anyway, thanks again. Sorry to have bothered you. It was not my intent.
|

November 17th, 2009, 06:34 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
No no no, you misunderstood me. First of all, you're not bothering me. I could simply decide ignore you if you did. ;-)
But you misunderstood my request. I asked you about the *client side* code; e.g. the HTML that ends up in the browser. This has nothing to do with server side code or stored procedures; but simply with the final HTML that ends up at the clinet.
Since you said the HTML looked good (or at least contained what you expected), it was clearly a client side issue, so looking at just the client HTML would have shed some light on the issue.
See what I mean? Are you aware of the differences between client side and server side code? (Not being funny, I see many developers that don't)
Imar
|

November 17th, 2009, 06:39 PM
|
Banned
|
|
Join Date: Jul 2005
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yes I am aware of client-side vs. server-side, and I knew what you meant. But I had discovered the Master Page thing by then, so I was good-to-go. I still haven't figured out what is causing it within the Master Page, but as you suggested originally, I believe it's the CSS. So I'm delving into it as we speak.
I do know that I was confused on whether it was client-side or server-side until you mentioned it, which led me to test it without the Master Page/CSS. So your questions were very helpful.
I do thank you for your help. I wasn't intending on seeming unhappy with your help. I just felt bad that I posted it in the first place without more details and/or further testing.
Thanks for your help. You and the others on this forum are always helpful! Thanks Imar!
|
|
 |