S
satria
hi all,
i have a accesslevel table's that has 2 field, id and accesslevelname.
i successfully binded the table to datagrid, but i'd like to display a
new column, called number. so it 'll display :
number | accesslevelname
1 user
2 supervisor
....
i dont want to add the new column to the database.
i tried this code :
DataSet ds=new DataSet();
ds=CFM.component.accesslevel.GetDS();
DataTable table = ds.Tables["AccessLevel"];
table.Columns.Add(new DataColumn("no",typeof(int)));
int rowcount=table.Rows.Count;
for(int i=1;i<rowcount-1;i++)
{
table.Rows["no"]=i;
}
DataGrid1.DataSource=table;
DataGrid1.DataBind();
but i always get error
"Object reference not set to an instance of an object." at line
"table.Columns.Add(new DataColumn("no",typeof(int)));".
pls hlp me
regards
satria
i have a accesslevel table's that has 2 field, id and accesslevelname.
i successfully binded the table to datagrid, but i'd like to display a
new column, called number. so it 'll display :
number | accesslevelname
1 user
2 supervisor
....
i dont want to add the new column to the database.
i tried this code :
DataSet ds=new DataSet();
ds=CFM.component.accesslevel.GetDS();
DataTable table = ds.Tables["AccessLevel"];
table.Columns.Add(new DataColumn("no",typeof(int)));
int rowcount=table.Rows.Count;
for(int i=1;i<rowcount-1;i++)
{
table.Rows["no"]=i;
}
DataGrid1.DataSource=table;
DataGrid1.DataBind();
but i always get error
"Object reference not set to an instance of an object." at line
"table.Columns.Add(new DataColumn("no",typeof(int)));".
pls hlp me
regards
satria