tags:

views:

53

answers:

2

Hi,

I'm making a custom webpart. I takes some items from a list and display them with a SPGridView.

I bound the fields like this:

// Grab data from a SP List into dvwTickets
SPGridView grdMyTickets = new SPGridView();
grdMyTickets.DataSource = dvwTickets;
[..]
BoundField colTicketTypology = new BoundField();
colTicketTypology.DataField = "ID";
colTicketTypology.HeaderText = ticketList.Fields.GetFieldByInternalName("ID").Title;
grdMyTickets.Columns.Add(colTicketTypology);
[..]

This works. Now, what a grid does behind the scene when binding data to it is cycling through the binded data. How can I access the "Current Item" to make operations on each item while binding?

Thanks

A: 
  1. You should probably use SPBoundField to format fields accordingly.
  2. Override SPGridView.OnRowDataBound event which will be called on each row.
Janis Veinbergs
A: 

A little late reply but I think you need to subscribe to events on the dvwTickets instance. There might be some event there that suit your needs, e.g. onDataBound()

armannvg