FieldCount; ++i)
{
columnName = new TableCell();
headerRow.Cells.Add(columnName);
columnName.Text = temp.GetName(i);
}
}
if (dataRow is DataRowView)
{
DataRowView drv = (DataRowView)dataRow;
for (int i = 0; i < drv.Row.Table.Columns.Count; ++i)
{
columnName = new TableCell();
headerRow.Cells.Add(columnName);
columnName.Text = drv.Row.Table.Columns[i].Caption;
}
}
headerRow.HorizontalAlign = HorizontalAlign.Center;
headerRow.BackColor = HeaderRowBackColor;
headerRow.ForeColor = HeaderRowForeColor;
}
}
}
Listing 7-15. The EnhancedSpreadsheetRow Control
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ControlsBook2Lib.Ch07
{
public class EnhancedSpreadsheetRow : TableRow, IDataItemContainer
{
private object data;
private int _itemIndex;
CHAPTER 7 ?– SERVER CONTROL DATA B INDING 341
public EnhancedSpreadsheetRow(int itemIndex, object o, bool dataBinding)
{
if (dataBinding)
{
data = o;
_itemIndex = itemIndex;
}
}
public virtual object Data
{
get
{
return data;
}
}
object IDataItemContainer.DataItem
{
get
{
return Data;
}
}
int IDataItemContainer.DataItemIndex
{
get
{
return _itemIndex;
}
}
int IDataItemContainer.
Pages:
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454