Add an automatic number function for DataGrid

xiaoxiao2021-03-06  51

Add events: ?? Every time you are bound to the DataGrid control after the item is broken

Private void

DataGrid1_itemdatabase (Object Sender, System.Web.ui.WebControls.DataGriditeMeventArgs E)

?? {

??? if (E.Item.itemindex! = - 1)

??? {

???? E.Item.cells [0] .Text = (E.Item.itemindex 1) .tostring ();

???}

?

?

?

?

If there is a paging:

?

// ?? Every time I have been bind to the DataGrid control after the item is ?? private void

DataGrid1_itemdatabase (Object Sender, System.Web.ui.WebControls.DataGriditeMeventArgs E)

?? {

??? if (E.Item.itemindex! = - 1)

??? {

???? Int pagein = this.dataGrid1.currentpageindex;

???? Int size = this.dataGrid1.pageSize;

???? Int sum = pagein * size;

???? E.Item.cells [0] .text = (SUM E.Item.itemindex 1) .tostring ();

???}

??}

?

Private void

DataGrid1_pageIndexchanged (Object Source, System.Web.ui.WebControls.DataGridPageChangeDeventargs E)

?? {

??? this.DataGrid1.currentpageindex = E.NewpageIndex;

??? this.DataShow ();

??}

There is also a simpler way:

Add a template column

<% # grid.currentpageindex * grid.pagesize grid.Items.count 1%>

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

New Post(0)