Gridview Customised Delete action

R

Rabbit

Hi,

I'm having a GridView with Datasource being set from CodeBehind method, its
has a "RecID" databound field set as invisible.

I want to utilize the "Delete" commandfield, so that on gridview_RowDeleting
event, i can perform a customised delete action.

I've tried me.gridview.Rows(e.RowIndex).Cells(intField).Text, which only
works for "visible" field

My problem is now on such RowDeleting Event, I don't know how to access such
invisible "RecID" databound field, can anyone tell me what should i do for
achieving such field's value?
 
A

agapeton

A GridView doesn't count invisible columns as real columns... so you
have to go directly to the data.

When in debug mode, set a breakpoint in the RowDataBound method (which
yuo assigned to that event).

Look for something like the following
(string)((DataRowView)e.Row.DataItem)[1]

This will get you the information in that column...
 
R

Rabbit

Thanks, I have just found another way to retrieve that invisible column,
because its my Data Key of the record, so I set the "DataKeyNames" attribute
of the GridView

then on the RowDeleting event, i can use following syntax to retrieve it!
Me.gvMaterialPO.DataKeys.Item(e.RowIndex).Value
 
A

agapeton

Yeah that'll work too... point is that you can't just access the
column. You have to do it via data.
 

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

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top