GridView Question

G

Gunawan

Dear All,
I have data which display on the GridView.
GridView contain 3 Column (ProductId, ProductCode and Description).
I would like to display only Product Code and Description so I hide
ProductId Column.
Is there any command so I can take value of first column which is Product
ID?
In other words, how can I get value from hidden column on Grid View?

TIA,
Gun
 
O

offwhite

The value should still be there and available like the shown values.
Walk through it with the debugger and place breakpoint in the Load
event. Then add your GridView reference to the Watch. You can expand
it out to see exactly where you can find your value.

Placing an ID as a hidden column on a GridView is common practice and
it was done with the DataGrid in ASP.NET 1.1. It is the only real way
to know what data that row was bound to originally.

Brennan
 
G

Gunawan

Actually I am using SelectedRow Object
GridViewRow row = gv1.SelectedRow;

But I can not get value from column #1 which I hide

Or I should use something else?

FYI I use gv1.DataSource = ds
ds is a dataset object, instead I bound it with SQL Data Source

TIA,
Gun
 
D

David Wier

One thing I've used in this case, was to duplicate the label (or whatever
control), along with its databindings inside one of the visible controls, as
a template -
then, make that control invisible - - the column is visible, but the control
is not - but it's still available to get the value

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
 

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