Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Populating a Datagrid

Reply
Thread Tools

Populating a Datagrid

 
 
Lee
Guest
Posts: n/a
 
      01-21-2004
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


 
Reply With Quote
 
 
 
 
Gerald Klein
Guest
Posts: n/a
 
      01-21-2004
WHat do you mean by recordset? Old ASP? You can use anything that implements
ICollection as a datasource


"Lee" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
ONIL@
Guest
Posts: n/a
 
      01-22-2004
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
--
ONil@.
MX.

"Lee" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populating a DataGrid Bob Hollness ASP .Net 4 01-12-2005 07:43 PM
Populating a datagrid ... how is it done normally? Prime ASP .Net 2 10-01-2004 01:35 AM
Datagrid Dropdown not populating =?Utf-8?B?VGltOjouLg==?= ASP .Net 1 08-20-2004 01:39 PM
Timeout on populating a datagrid Paul ASP .Net 4 05-05-2004 06:36 PM
Populating a datagrid from two separate data sources John ASP .Net 1 07-31-2003 06:46 AM



Advertisments