p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 3.5 Basics (http://p2p.wrox.com/forumdisplay.php?f=351)
-   -   DataList is Showing Up in Source Code, But Not On Web Page? (http://p2p.wrox.com/showthread.php?t=77069)

kwilliams November 17th, 2009 04:47 PM

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?

Imar November 17th, 2009 05:00 PM

- 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

kwilliams November 17th, 2009 05:29 PM

- 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


Imar November 17th, 2009 05:57 PM

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

Imar November 17th, 2009 06:05 PM

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

kwilliams November 17th, 2009 06:10 PM

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!

Imar November 17th, 2009 06:19 PM

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

kwilliams November 17th, 2009 06:22 PM

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.

Imar November 17th, 2009 06:34 PM

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

kwilliams November 17th, 2009 06:39 PM

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!

meet_rajput January 20th, 2016 02:15 PM

<asp:TextBox ID="TextBox2" placeholder=" movie " Style="font-size:20px; width:445px;" list="tp" runat="server" Width="185px"></asp:TextBox>
<datalist ID="tp" runat="server">
<option value="Murder">Murder</option>
<option value="Raaz">Raaz</option>
<option value="Dhoom3">Dhoom3</option>
<option value="DDLJ">DDLJ</option>
<option value="Dilwale">Dilwale</option>
<option value="Bajirao">Bajirao</option>

</datalist>

This code is working in normal aspx page but not supports the same effect in master page..
Please Help..!!!


All times are GMT -4. The time now is 11:07 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.