Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 8th, 2005, 10:57 AM
Registered User
 
Join Date: Apr 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding customised rows to datagrid

Hi

I'm fairly new to .NET and I'm having a problem with dynamically adding rows to a datagrid.

I can populate, edit, save the datagrid fine, but for each item in that datagrid I want to be able to add a new row underneath it to allow a large "Comments" textbox to be displayed (basically there isn't enough room to display the Comment in the row, so I'm trying to add a new row underneath each item)!

Can anyone advise if this is possible, and if so be able to guide me in the right direction of achieving the above?

Many thanks

Dan

 
Old April 9th, 2005, 05:03 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You can use template columns in the datagrid. Perhaps a template column with a larger textbox might work.

Otherwise, I'm not sure if you can do what you are asking. The datagrid is a pretty rigid control regarding how it renders itself from what I have found. You can make all kinds of changes to the columns of one row, but adding a row is another story.

Perhaps you might be better off to try this:

Manipulate your data source before you bind to the grid. Add rows to the source data (which is MUCH easier). You can flag the row somehow to indicate that it's the "comments" row. Then you can deal with the row in the grid's ItemDataBound event handler. Make whatever column changes you need in that row. The grid will actually help you out with flagging the row because all the rows you add on (one comments row for each data row) will actually end up being the grid's 'Alternate Item' (versus 'Item'). So then you just need to manipulate the comment row's columns to fit your needs.

-Peter
 
Old April 11th, 2005, 05:35 PM
Registered User
 
Join Date: Apr 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Peter, many thanks for the advice. I'll give it a go!

Dan






Similar Threads
Thread Thread Starter Forum Replies Last Post
adding all the rows to get a total value KeviJay SQL Language 2 May 29th, 2008 03:22 AM
Problem with adding rows to database gule2902 Visual Basic 2005 Basics 4 September 13th, 2007 05:10 PM
Dynamically adding DataGrid rows lepreston ASP.NET 1.x and 2.0 Application Design 3 November 22nd, 2006 04:33 AM
Adding new rows to Datagrid MixedCode General .NET 1 April 10th, 2005 05:00 PM
adding rows to datatable forkhead ADO.NET 2 March 18th, 2004 01:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.