Merged DataGrid in ASP.NET

xiaoxiao2021-03-06  73

E.g:

Name Metering Unit, Industrial Economy AAA 10,000 yuan, industrial economy BBB

Combined as:

Serial Name Metering Unit, Industrial Economy AAA Wan Yuan BBB just combined with multiple lines of first columns, how to achieve? Thank you all!

Implementation method: Try the frankly pen to this to try this: On the .aspx page, in onprerenter = "fdgrid_prender">

In the .cs file:

// Merge the same cell public void fdgrid_prerenter (object sender, system.eventargs e) {if (this.fdgrid.Items.count <= 1) {return;} col = 0; TableCell Oldtc = this.fdgrid.IndTC = this.fdgrid.Items [ 0] .cells [color]; for (int i = 1; i

Of course, you can also process it with itemDatabase. The specific details are joined in the initializationComponent method in the .CS file: this.dgcontacts.itemdatabase. = New system.Web.ui.WebControls.DataGriditeMeventHandLer (this.dgcontacts_itemdatabase;

Add: if (! Page.ispostback) {LastIndex = 0;}

Where DGContacts is the name of DataGrid

Then add the following code .cs file: int lastIndex; protected void dgContacts_ItemDataBound (object source, System.Web.UI.WebControls.DataGridItemEventArgs e) {if (e.Item.ItemType == ListItemType.Item || e.Item .ItemType == ListItemType.alternatingItem) {string ismanager = (string) DataBinder.eval (E.Item.DataItem, "serial number"); int INN = E.Item.itemindex; TableCell C; int coL = 0; IF (Inn > 0) {IF (DGContacts.Items [LastIndex] .cells [col] .text == ismanager) {c = new Tablecell (); c = E.Item.cells [col]; if (DGContacts.Items [LastIndex] .Cells [col] .ROWSPAN == 0) DGCONTACTS.ITEMS [LastIndex] .cells [col] .rowspan = 1; DGContacts.Items [LastIndex] .cells [col] .rowspan = 1; Response.write (DGContacts.Items [LastIndex] .cells [col ].RowSpan; E.Item.cells.remove (c);} else {E.Item.cells [col] .text = ismanager; LastIndex = E.Item.ItemIndex;}} else {E.Item.cells [col] .text = ismanager;} }

Both methods can be, but it is also the first way, and the versatility is also strong. If the second method, if it is slightly modified, it should be. There may be other methods. In particular, it is not important to use it. It is important to flexibly apply basic knowledge to solve complex problems.

转载请注明原文地址:https://www.9cbs.com/read-109015.html

New Post(0)