Use
Imports System.Data.SqlClient
and
Imports System.Data
collections if you use sql server.
To bind to the data grid
'2. Create the command object, passing in the SQL string
Const strSQL As String = ';select * from pcsystems';
Dim myCommand As New SqlCommand(strSQL, myConnection)
'Set the datagrid's datasource to the datareader and databind
myConnection.Open()
Grid1.DataSource = myCommand.ExecuteReader(CommandBehavior.鈥?br>
Grid1.DataBind()
call databind function on form load..... Thats allWhat is the collection base in the Vb.Net?? and how can i use it to bind an objects into a datagrid?
You can use 'SetDataBinding' procedure of the datagrid.
eg:
with datagrid1
.TableStyles.Add(dgtsMyTable)
.SetDataBinding(dtMyTable, ';';)
end with
where
dtMyTable = The table to be bound with the datagrid.
dgtsMyTable = The datagridTableStyle for the table MyTable
No comments:
Post a Comment