0

So I've used datagrids a few times, but never with a masterpagefile. I thought it would be the same, but it doesn't seem to be working for me...

<%@ Page Title="Products" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
    CodeBehind="Default.aspx.vb" Inherits="F._Default" Debug="true" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script runat="server">
    Sub Page_OverLoad()
        Dim dbconn, sql, dbcomm As Object
        dbconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("guitars.mdb"))
        sql = "SELECT * FROM guitars"
        dbcomm = New OleDbCommand(sql, dbconn)
        dbconn.Open()
        
        dgGuitars.DataSource = dbcomm.ExecuteReader()
        dgGuitars.DataBind()
        
        dbconn.Close()

    End Sub
</script>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:DataGrid id="dgGuitars" runat="server" 
              BackColor="#eeeeee" width="85%" 
              HorizontalAlign="Center"
              font-name="verdana" CellPadding="4" 
              Font-Size="10pt" >

                <HeaderStyle backcolor="Black" forecolor="White" font-bold="True" horizontalalign="Center" />
                <AlternatingItemStyle BackColor="White" />
            </asp:DataGrid>
</asp:Content>

I'm guessing it's something extremely simple I'm overlooking, it usually is.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by phoenix911
0

while debugging did you get data back from the server?
In other words does the bold code below return anything

dgGuitars.DataSource = [B]dbcomm.ExecuteReader()[/B]

also maybe consider adding

[B]user id[/B] & [B]password[/B]

to you connection string?

Edited by phoenix911: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.