On Wed, 17 Jan 2007 08:26:00 -0800, Randy
<> wrote:
>Hi,
>In the old datagrid control in VS2003 the text in a cell could be accessed
>by using the following sysntax:
>e.Item.Cells(1).Text
>
>What is the Corresponding code to access the text in a cell of a new
>gridview control?
>
>Thanks for any help
You can access the items in the grid via the OnRowDataBound event
with:
e.Row.Cells[0].Text
(for intance - for data in the first column)
You can iterate through the row with something like
if (e.Row.RowType == DataControlRowType.Header)
{
foreach (TableCell tc in e.Row.Cells)
{
tc.Text = tc.Text + ....
}
}
(for intance for the column headers)
If your GridView has DataKeyNames set equal the the key of the
DataView which populates the Grid then the record key on a particular
row (DataKey) will be:
gvManagers.DataKeys[e.Row.DataItemIndex].Value
(for instance for a GridView called gvManagers)
|