Na een halve middag tutorials gelezen te hebben en een hoop ergenis krijg ik het nog steeds niet voor elkaar om iets simpels als een DataGrid te vullen. Compilen gaat prima Visual Studio 2003.
DB bevat gegevens maar de aspx pagina blijft akelig leeg. Zit ik nu te slapen of is er gewoon iets niet goed ?
Codebehind:
ASPX Page
DB bevat gegevens maar de aspx pagina blijft akelig leeg. Zit ik nu te slapen of is er gewoon iets niet goed ?
Codebehind:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
If Not Page.IsPostBack Then
BindGrid()
End If
End Sub
Sub BindGrid()
Dim ConnectionString As String = "server=(local)\NetSdk;database=Northwind;trusted_connection=true"
Dim CommandText As String = "SELECT * FROM Products ORDER BY ProductName"
Dim myConnection As New SqlConnection(ConnectionString)
Dim myCommand As New SqlDataAdapter(CommandText, myConnection)
myConnection.Open()
Dim ds As New DataSet
myCommand.Fill(ds)
DataGrid1.DataSource = ds
DataGrid1.DataBind()
myConnection.Close()
End Sub |
ASPX Page
code:
1
2
3
4
5
6
7
8
9
10
| <asp:datagrid
id="DataGrid1" runat="server" ForeColor="Black"
BackColor="White" GridLines="None" CellPadding="3"
CellSpacing="1"
width="80%">
<HeaderStyle Font-Bold="True" ForeColor="white"
BackColor="#4A3C8C">
</HeaderStyle>
<ItemStyle BackColor="#DEDFDE"></ItemStyle>
</asp:datagrid> |
[ Voor 15% gewijzigd door Friedchicken op 14-11-2005 17:59 ]