Adding rows dynamically to a datagrid

R

Ram

Hi,

Pls could anyone tell me how to do the following task.

I am having a datagrid with certain columns. Now what i need is , I
have to include a button in each row and on clicking this button , i
have to generate a similar row below the row that have clicked . ie
like a child row for the parent row in which i have clicked the button.


Thanks and Regards,
S.Ramalingam
 
G

Guest

Hi Ram,

Suppose you are using a DataTable as data source of the datagrid. In
datagrid_ItemCommand event,

DataTable table = getTable_Method();
int index = e.Item.ItemIndex;
DataRow AddedRow = table.NewRow();
AddedRow.ItemArray = table.Rows[index].ItemArray;
table.Rows.InsertAt(index + 1, AddedRow);
datagrid.DataSource = table;
datagrid.DataBind();

HTH

Elton Wang
 

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,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top