Adding new column to dataset

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top