Author: Unknown author please contact me speed
Serial number
content
1
Taye
2
Box
3
Glass
4
Starcraft
First, positive order
A, sopaging = false
It can be implemented, but more interesting methods is to use this method.
Maybe some people feel very strange why it is like this, not all the contracts .. But if you understand the binding process, it is easy to understand. [From above, it is binding in the itemcreated event. Items.count is just the current number] b, sopaging = "true" If your DataGrid supports paging, you can follow
Second, reverse order
Serial number
content
4
Taye
3
Box
2
Glass
1
Starcraft
From the above, it is impossible to use this.DataGrid1.items.count - Container.itemindex 1 method, it is impossible to achieve a value and all the best in the case of 1 point. So we will get the data source. number
.CS
Private int rot = 0;
Protected int ROWSCOUNT
{
Get {return rowscount;}
Set {this.rowscount = value;
}
Private Void Page_Load (Object Sender, System.EventArgs E)
{
/ / Place the user code here to initialize the page
IF (! ispostback)
THIS.BINDDATA ();
}
Private void binddata () {
SqlConnection CN = New SQLCONNECTION ("Server = (local); database = northwind; uid = sa; pwd =");
String str = @ "Select Employees.employeeiD, Orders.employeID
From Employees Inner Join
ORDERS on Employees.employeeid = Orders.employeeid ";
SqldataAdapter Sqlda = New SqldataAdapter (STR, CN);
DataSet DS = New DataSet ();
Sqlda.fill (DS);
This.Rowscount = ds.tables [0] .rows.count;
THIS.DATAGRID1.DATASOURCE = DS;
THIS.DATAGRID1.DATABIND ();
}
.aspx
<% # Rowscount - DataGrid1.currentPageIndex * DataGrid1.pageSize - Container.Index%>
Itemtemplate>
asp: templateColumn>
Columns>
ask: DataGrid>
Of course, if it is not a paging, it is easier to implement.