DataGrid hidden custom value

  • Thread starter Mike Gleason jr Couturier
  • Start date
M

Mike Gleason jr Couturier

Hi,

I want to store the ID of the database row to each of the datagrid row...
(I don't want the ID to be visible.)

In other words, on the Row Command event, I want to be able to retreive the
database row id.

I tried with a datagrid column (visible = false) but it doesn't work

Any ideas!?

Thanks
 
M

Mike Gleason jr Couturier

Mike Gleason jr Couturier said:
Hi,

I want to store the ID of the database row to each of the datagrid row...
(I don't want the ID to be visible.)

In other words, on the Row Command event, I want to be able to retreive
the database row id.

I tried with a datagrid column (visible = false) but it doesn't work

Any ideas!?

Thanks

Hi Mike,

Maybe you can try to create an HiddenField somewhere in your page. This
field will contain the value of the database ID of the clicked row of the
datagrid...

For each button of you datagrid, you set a javascript on the OnClientClick
(or something) that will change the hidden field :
onclick="javascript:document.getElementById('hiddenfield').value =
'<rowdbid>';"

In onrowcommand, you can then access the database id of the clicked row..

That should do it

Mike
 
M

Mike Gleason jr Couturier

Mike Gleason jr Couturier said:
Hi Mike,

Maybe you can try to create an HiddenField somewhere in your page. This
field will contain the value of the database ID of the clicked row of the
datagrid...

For each button of you datagrid, you set a javascript on the OnClientClick
(or something) that will change the hidden field :
onclick="javascript:document.getElementById('hiddenfield').value =
'<rowdbid>';"

In onrowcommand, you can then access the database id of the clicked row..

That should do it

Mike

Wow thanks Mike!!

Mike
 
M

Mike Gleason jr Couturier

colin_nz via DotNetMonster.com said:
If you look up GridView.SelectedDataKey Property, that may be useful in
your
situation

Much cleaner/client compatible code... thanks!

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

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top