New column in datagrid.

M

MA

Sorry...did a mistake on my last message :)

So....I have this code:
private void buildGrid()

{

DataTable dt = new DataTable();

//Create columns in datagrid

dt.Columns.Add(new DataColumn("Code", typeof(string)));

dt.Columns.Add(new DataColumn("Name", typeof(string)));

dt.Columns.Add(new DataColumn("Color", typeof(string)));

dt = buildDataTable(dt);


DataView dv = new DataView(dt);


dgActivityType.DataSource = dv;

dgActivityType.DataBind();

}

private DataTable buildDataTable(DataTable dt)

{

//Create database connection

connection db = new connection(connectstring);

SqlDataReader sdr = db.execStoredProc("proc_get", "");

DataRow dr;

while(sdr.Read())

{

dr = dt.NewRow();

dr[0] = sdr["atCode"].ToString();

dr[1] = sdr["atName"].ToString();

dr[2] = sdr["color"].ToString();

dt.Rows.Add(dr);

}

sdr.Close();

db.Close();

return dt;

}



But how do I add a EditCommandColumn to this? And how do i place it in the
last column, instead of the first?



/Marre
 

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

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,123
Latest member
Layne6498
Top