Geir:
You can only use a DataReader to bind to a ASP.NET Grid...it won't work for
a Windows.Forms grid. Since the ASP.NET grid doesn't support editing , you
have to kind of work it in behind the scenes. Anyway, the main reason you'd
go with a datatable is for paging, sorting and filtering (although from what
I've seen, that's all going to be built into ASP.NET 2.0)
If you are using a Web Grid, just the teh datasource = cmd.ExecuteReader();
If it's a desktop grid, you are going to have to loop. The overhead
difference can be big between using a reader and a DataAdapter but if you
keep your queries small, everything should be 'ok' performance wise. If you
are looping though, you are going to create a datatable and bind to it
anyway so any performance increase will be more than offset by the code
complexity.
AFAIK, there's not native support for the two row thing, but like anything
else, you can provide that functionality yourself. If you check out
www.knowdotnet.com Les' new grid class does have a multiline textbox column
which may be what you need.
If you are going to hide a field in a combobox, then just use the
DisplayMember (the datafield you want to appear in the combobox) if you are
using Windows Forms or DataTextMember for the Web, and ValueMember (the
actual value field you want, in this instance, the 'hidden field') or
DataValueField if you are using the web. This is a lot cleaner and you can
used SelectedItem to get the text values, and SelectedValue to get the ID or
hidden field.
HTH,
Bill
"Geir Holme" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> Hi all.
> As I read about .NET i see that we should use a datareader to read data.
> Well, that's OK, but is this det best way of filling a Datagrid just for
> reading. I don't want to use a listboks because I want to add some collors
> to the cells depending on the values and so on. So, is there an easy way
to
> fill a datagrid from a datareader without looping arroun each row and each
> cell. If not, is this looping more effektive than connecting a dataset to
> the datagrid an .fill the adapter?
>
> Or is there another fast and easy way of filling the datagrid.
>
> And some simple ones.
>
> Does the datagrid support multirow. (One record displayed over 2 rows in
the
> grid).
> Does the combo in .NET support multicolumn. (Typically hide the ID
column).
>
> Thanx all
>
>
> -geir
>
>