473,834 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Add an new row in DataGrid programmaticall y?

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_Item DataBound(objec t sender,
System.Web.UI.W ebControls.Data GridItemEventAr gs e)
{

if(e.Item.ItemT ype == ListItemType.It em)
{
DataGridItem dataGridItem = new DataGridItem(0, 0,ListItemType. Item);

TableCell tableCell = new TableCell();
tableCell.Colum nSpan = 8;
tableCell.Text = "This is the job which is... ";
dataGridItem.Ce lls.Add(tableCe ll);
ADDataGrid.Cont rols[0].Controls.Add(d ataGridItem);
}
}
But it did not do anything for me. Why?
Thanks for any reply!
Nov 19 '05 #1
1 1921
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_Item DataBound(objec t sender,
System.Web.UI.W ebControls.Data GridItemEventAr gs e)
{

if(e.Item.ItemT ype == ListItemType.It em)
{
DataGridItem dataGridItem = new DataGridItem(0, 0,ListItemType. Item);

TableCell tableCell = new TableCell();
tableCell.Colum nSpan = 8;
tableCell.Text = "This is the job which is... ";
dataGridItem.Ce lls.Add(tableCe ll);
ADDataGrid.Cont rols[0].Controls.Add(d ataGridItem);
}
}
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
1981
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
1359
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 built-in editing functionality of the DataGrid). The DataGrid is bound.
0
2408
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 CheckBox Programmatically" in my code. I have changed it to use a OLDDB.DBReader to populate the datagrid and for the databinding. It works perfectly - also when using the edit-mode in the datagrid.
1
1854
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 = ButtonColumnType.PushButton
0
1108
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 columns programmatically (templatecolumns). This part works fine. Next, I am adding ImageButtons to the headers of the columns, which I am attaching events to and using to sort the datagrid based on the given column. This works with one major problem -...
5
1445
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 DataGrid to its fullest when you "drop" it on a web form. There you can modify all sorts of properties for the look and behaviour to your hearts content. But then, when you decide to use the DataGrid as a child control of a web custom composite...
2
2214
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 new row to my datagrid. Thanks in advance.
7
15011
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 MyList data is resident in a dataset table. I'm stuck and can't choose either because. If I choose ListView as my control I don't understand how to programmatically get the data from the dataset table
9
9773
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 next step. Situation: I have a form (Form 1) with a datagrid that has a context menu for adding updated records. When selecting the "Add Option" a second form (Form 2) is displayed for data population. The user saves the
4
2924
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
9799
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10795
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10550
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9332
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5627
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5796
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3981
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.