It's absolutely possible with the DataGrid. The trick is to disable the AutoGenerateColumns property of the control. Next, you can use the datagrid columns editor to add the columns you want to display. In order to keep the hidden ID around without the need to re-query the database, you should also use a custom templated column where you put the ID in a control with a hidden style (i.e. set its Class property, and create a CSS style with "display:none").
Afterwards, you can locate the ID for a row by using the FindControl( id ) method.
Finally, paging is *not* automatic. You must handle the PageIndexChanged event fired by the datagrid, where you basically set the new index, and rebind the data:
private void grdApproved_PageIndexChanged(object source,
DataGridPageChangedEventArgs e)
{
// Set the new index
grdApproved.CurrentPageIndex = e.NewPageIndex;
// Re-fill the dataset
adApproved.Fill(dsApproved);
// Re-bind
grdApproved.DataBind();
}
This was first published in June 2004