J
Jonas Nilsson
Hi!
Does anyone have a sample on how i can inherit the datagrid in a Web Control
and bind it to a datasource.
And then add template columns and add data from the datasource into the
columns
My Web Control inherits the DataGrid, i bind the control to a datasource
(DataReader) in my aspx code (Page_Load event)
But i can't get data from the DataItem in OnItemDataBound event in my Web
Control.
protected override void OnItemDataBound(DataGridItemEventArgs e)
{
LinkButton lb = new LinkButton();
lb.ID = "lbNav";
*** This row causes a "Object reference not set to an instance of an
object" ***
lb.Text = ((DataRowView)e.Item.DataItem).Row.ItemArray[1].ToString();
e.Item.Cells[0].Controls.Add(lb);
base.OnItemDataBound (e);
}
/Jonas
Does anyone have a sample on how i can inherit the datagrid in a Web Control
and bind it to a datasource.
And then add template columns and add data from the datasource into the
columns
My Web Control inherits the DataGrid, i bind the control to a datasource
(DataReader) in my aspx code (Page_Load event)
But i can't get data from the DataItem in OnItemDataBound event in my Web
Control.
protected override void OnItemDataBound(DataGridItemEventArgs e)
{
LinkButton lb = new LinkButton();
lb.ID = "lbNav";
*** This row causes a "Object reference not set to an instance of an
object" ***
lb.Text = ((DataRowView)e.Item.DataItem).Row.ItemArray[1].ToString();
e.Item.Cells[0].Controls.Add(lb);
base.OnItemDataBound (e);
}
/Jonas