473,406 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to Add an new row in DataGrid programmatically?

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!
Nov 19 '05 #1
1 1901
Hi Nicky,

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

Cheers,

Jerome. M

"Nicky" wrote:
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!

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: ad | last post by:
I use the code to create a DataGrid and filled with data, But the DataGrid1 didn't display in WebForm. How can I display the DataGrid after creating it? DataGrid DataGrid1 = new DataGrid();
0
by: Mark Kamoski | last post by:
Everyone-- I have a DataGrid that is bound at run-time. Upon the click of the Add, a new row is added to the top and it has several types of controls, (but, it is not permissible to use the...
0
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a...
1
by: Steve Black | last post by:
Hello, I am trying to add an EditCommand Button to a datagrid. If I programmatically add the button, like this: Dim eb As EditCommandColumn eb = New EditCommandColumn With eb .ButtonType...
0
by: Chris | last post by:
Ok, I think this is an easy one - I've just been staring at it too long. I'm creating a datagrid in asp.net/c# from scratch, i.e. nothing at all in the aspx page. I'm also creating all the...
5
by: ~~~ .NET Ed ~~~ | last post by:
Well, maybe not half-baked but 75%. I find very frustrating working with the DataGrid control. It offers a lot of functionality which really comes in handy. Unfortunately you can only enjoy a...
2
by: jaYPee | last post by:
Anyone know how to add record to a datagrid programmatically? Say for example I have two textboxes in my form and a datagrid. When I click a button the value of two textboxes will be added as a...
7
by: BobAchgill | last post by:
I am trying to decide which of these controls to use to implement letting my user select a full row from MyList. The MyList has several columns which would be nice to sort by at run time. The...
9
by: mfahnestock | last post by:
Hi all! Aspiring VB programmer losing hair <And Sleep> over this problem. I have spent several days researching through the various usenets and resources to no avail, and so now I am taking the...
4
by: gane | last post by:
Hi, I am creating datagrid bound column dynamically and need to check if a datagrid column already exists?Is there a way to check this? thanks gane
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.