How to Add an new row in DataGrid programmatically?

G

Guest

hi, all

I have a asp.net page, and there is a DataGrid in it. I want show it like
Header: ID, StartTime, EndTime.......
1 12:20 12:40
This is the job which is ........
2 14:30 14:45
This is the second job ........
Here, each item contains two row.What is the best solution for this? Or I
should not use DataGrid for it?
What I did is response ItemDateBound message, for each item, add an new item
to display the description "This is the job...."
private void ADDataGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{

if(e.Item.ItemType == ListItemType.Item)
{
DataGridItem dataGridItem = new DataGridItem(0,0,ListItemType.Item);

TableCell tableCell = new TableCell();
tableCell.ColumnSpan = 8;
tableCell.Text = "This is the job which is... ";
dataGridItem.Cells.Add(tableCell);
ADDataGrid.Controls[0].Controls.Add(dataGridItem);
}
}
But it did not do anything for me. Why?
Thanks for any reply!
 
G

Guest

Hi Nicky,

You can't do so with datagrid....but you can do it with DataRepeater
control, even with datalist too.

Cheers,

Jerome. M
 

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,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top