Datagrid layouts

G

Guest

Hello

I have a datagrid and i have set autogenerate columns to false, i then have
two bound columsn that display whatever it should. However there is one
column that has the same result in it that i dont want to display in a column
i want to display just the once. Basically it is a current status of the
case that is being viewed.

I use a datareader and bind it to the datagrid. How can i display it only
the once.

TIA
 
E

Eliyahu Goldin

The simpliest solution would be to let the reader read that constant value
to a hidden column and, in the PreRender event. take the value from the
first row and assign it to the element you choose for rendering. Since
hidden columns are not sent to client, it won't effect the performance.

Eliyahu
 
J

Joey

I thought hidden columns were sent to the clients in v1.1. They changed
it in v2.0, right? The idea is that one should use DataKeys instead?
Maybe I misunderstood?
 
E

Eliyahu Goldin

Any web control with Visible=false is not sent to the client neither in 1.1
nor in 2.0. You can hide controls with applying css rule display:none, then
will be sent.

Using a constant column as a key field looks a bit odd to me.

Eliyahu
 
J

Joey

Okay I see. I guess I didn't realize that hidden datagrid fields were
never sent to the client. I really thought they were. But you could
still use them to hold things like PrimaryKeys, etc in 1.1.

I do agree that this is not a good practice. And I changed (by
neccessity) my evil ways in 2.0. I quickly found that they changed it
so that in the gridview you can't do that anymore. I also read several
posts where people complained about this. After doing a little research
I found that they built in "DataKeys" for this! And that certainly
does work well, now that I know about it!

JP
 
G

Guest

Do you know of any sites that have some sample code or talk about how to
achieve this. I am new to dot.net and i am unsure of how to do a lot of
things. I am using v1.1 by the way. The page is literally all the case
notes for an application and i ask for the current status in the query so
what it does is stick it in every row. I just want to be able to show it in
a label or header column or something without haven't to run the query again.
 

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

Top