Why do I get a Type 'BindingSource' is not defined. error?

geor68

New member
Joined
Nov 6, 2011
Messages
4
Programming Experience
Beginner
Hi,

I found the code below and when i run it I get the message Type 'BindingSource' is not defined. What do I need to do to get it to work. I just want to run it and try it out!!!!!!

<%@ Page Language="VB" debug="true"%>
<%@ Import Namespace="System.Windows.Forms" %>
<%@ Import Namespace="System.Object" %>
<%@ Import Namespace="System.Data" %>


<script language="VB" runat="server">
Private table As DataTable
Public Sub New()

table = New DataTable("MyTable")
table.Columns.Add("Id", GetType(Integer))
table.Columns.Add("Name", GetType(String))
table.Columns.Add("Car", GetType(String))

table.Rows.Add(1, "Name 1", "Ferrari")
table.Rows.Add(2, "Name 2", "Jaguar")
table.Rows.Add(3, "Name 3", "Ferrari")
table.Rows.Add(4, "Name 4", "Porsche")
table.Rows.Add(5, "Name 5", "Ferrari")
table.Rows.Add(6, "Name 6", "Porsche")

DataGrid1.DataSource = New BindingSource(table, Nothing)
End Sub
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim myFilter As String = "Ferrari"
Dim newTable As DataTable = New DataView(Table, "Car = '" & myFilter & "'", "Name DESC", DataViewRowState.CurrentRows).ToTable()
DataGrid1.DataSource = Nothing
DataGrid1.DataSource = New BindingSource(newTable, Nothing)
End Sub
</script>

<html>
<head></head>
<body>
<form ID="form1" runat="server">
<asp:DataGrid id=DataGrid1 runat="server" PagerStyle-Mode="NumericPages"
PagerStyle-Position="Top" HeaderStyle-BackColor="White" /><br />
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
</body>
</html>
 
Back
Top