Populating a Datagrid

L

Lee

Hi All,

I have a webform with a datagrid on it. The only way I have been able to
find to populate it, would be to bind it to a datacontrol dropped on the
same page.

The issue I have is, that all of our data access is done from a seperate
class so that it is in one place and I'd like to keep it that way and don't
want to have SQL calls from any of the webpage control directly.

I have been able to pass a recordset back to the webpage, but cant figure
out how I would populate the datagrid with it. Does anyone know if this can
be done?

Thanks

Lee Trotter
 
G

Gerald Klein

WHat do you mean by recordset? Old ASP? You can use anything that implements
ICollection as a datasource
 
O

ONIL@

Hi Lee !

You can use a DataTable like this :

Dim dt As DataTable

Dim dr As DataRow

Dim i As Integer

'create a DataTable

dt = New DataTable

dt.Columns.Add(New DataColumn("Name", GetType(String)))

dt.Columns.Add(New DataColumn("First.", GetType(String)))

dt.Columns.Add(New DataColumn("Last", GetType(String)))

'Make the rows and add data.

For i = 1 To 12

dr = dt.NewRow()

dr(0)= "Hi " & i+1
dr(1) = "Hi" & i+2


dr(2) = "Hi" & i+3

'add each row to the DATATABLE

dt.Rows.Add(dr)

Next

dr = dt.NewRow()

dt.Rows.Add(dr)

DataGrid1.DataSource = new DataView(dt)

DataGrid1.DataBind

I hope it helps
Best Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top