ASP.NET - Get gridview edit row to span across col

2019-07-31 10:31发布

问题:

I've got a grid control with 6 columns. I use the EditItemTemplate fields to display edit data and I'd like to customize this if possible. Right now, the EditItemTemplate will show any control that I put in there but it only displays it in the column in which the template is in. How can I get it to span across all 6 columns? For instance, the 6 columns are:

First Name | Last Name | Address | City | State | Zip

and when the user clicks the Edit button (in each row), I'd like to show those 6 for edit, but add 1 more control on a row below that, which spans all 6 columns:

First Name | Last Name | Address | City | State | Zip
------------------------------------------------------
UserComments
------------------------------------------------------

Any ideas how I can accomplish this or even if it can be done?

回答1:

You can modify the gridview control by hooking up to the OnRowCreated event.

I found a very comprehensive tutorial here: Rows and Columns Merging in ASP.NET GridView Control

In the posted article, the author takes a gridview like this:

And transforms it to this: