Non-displayed values in DataGrid that stay accessible in EditCommand event?

M

Mike

I've got an app with a DataTable that gets passed around and modified
by datagrids on 3 different asp.net pages. Not all columns need to be
displayed, but I need them all in the datagrid so I can call the
LoadDataRow method to update the DataTable "in place".

I've been using boundcolumns for the invisible fields, which worked
fine, but now I've run into an issue with them. On the second of the
3 pages, the user can modify certain values and if a row is modified
in the datagrid I immediately update the DataTable, so I've got some
code in the grid Grid EditCommand event that handles all this.

For some reason the boundcolumns that are set to visible = False all
return empty strings in the EditCommand event, even though they
contain legitimate values. At first I tried getting the values out
using e.item.cells(x).text - that didn't work. I've noticed in
certain other situations that I have to dimension a textbox, assign
the textbox to the cell in question and then read the textbox.text
value into a string var, so I tried that and it didn't work either.

Just to make sure the grid columns were all being populated I set
visible to true temporarily. Sure enough all columns had data *and* I
was able to fetch the values from the boundcolumns using both of the
methods described above.

So I guess my question, put concisely, is what is the best way to
store non-displayed values in a datagrid in a fashion that will allow
them to be easily accessed in the grid's EditCommand event?

TIA,
Mike
 
C

Cor

Hi Mike,

We have in this newsgroup our own specialist for datagrid, but that is for a
windowform.

Your question is not that simple I think that you will fast get an answer
here, but maybe you will get it in the newsgroup
micorosoft.public.dotnet.framework.aspnet.datagrid

I know it is not the best advice because in that newsgroup only 1 on the 3
questions is answered in december till now

But you can try

Cor
 
O

One Handed Man [ OHM ]

Well, if you are not going to see them why bother retreiving them. Simply
dont select the fields on the SQL command, that way you only need to alter
the fields you see and leave the others unchanged.

Regards - OHM

==============================================
I've got an app with a DataTable that gets passed around and modified
by datagrids on 3 different asp.net pages. Not all columns need to be
displayed, but I need them all in the datagrid so I can call the
LoadDataRow method to update the DataTable "in place".

I've been using boundcolumns for the invisible fields, which worked
fine, but now I've run into an issue with them. On the second of the
3 pages, the user can modify certain values and if a row is modified
in the datagrid I immediately update the DataTable, so I've got some
code in the grid Grid EditCommand event that handles all this.

For some reason the boundcolumns that are set to visible = False all
return empty strings in the EditCommand event, even though they
contain legitimate values. At first I tried getting the values out
using e.item.cells(x).text - that didn't work. I've noticed in
certain other situations that I have to dimension a textbox, assign
the textbox to the cell in question and then read the textbox.text
value into a string var, so I tried that and it didn't work either.

Just to make sure the grid columns were all being populated I set
visible to true temporarily. Sure enough all columns had data *and* I
was able to fetch the values from the boundcolumns using both of the
methods described above.

So I guess my question, put concisely, is what is the best way to
store non-displayed values in a datagrid in a fashion that will allow
them to be easily accessed in the grid's EditCommand event?

TIA,
Mike

Best Regards - OHMBest Regards - OHM (e-mail address removed)
 
M

Mike

Not a bad suggestion, but I was hoping to be able to update the
DataTable using the LoadDataRow method. I can do as you say, but I
think it would require quite a bit more code, and once I find a really
strange situation like this one, I usually am not satisfied until I
know exactly what's going on. These things just nag at me - perhaps
you can relate!

Anyway, thanks - if I don't get through this soon I can always use
your advice.

Mike
 

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