ds=service1.SelRetds2("gzwj_view","",sortfield.ToString());
DataColumn sequence=new DataColumn();
sequence.DataType=System.Type.GetType("System.Int32");
sequence.AllowDBNull=false;
sequence.Caption="sortnum";
sequence.ColumnName="count";
ds.Tables[0].Columns.Add(sequence);
for(int i=0;i<ds.Tables[0].Rows.Count;i++)
{
ds.Tables[0].Rows[i]["count"]=i+1;
}
DataView source=new DataView();
source=ds.Tables[0].DefaultView;
DataGrid1.DataSource=source;
DataGrid1.DataKeyField="BH";
DataGrid1.CurrentPageIndex=page_no;
DataGrid1.DataBind();
DataColumn sequence=new DataColumn();
sequence.DataType=System.Type.GetType("System.Int32");
sequence.AllowDBNull=false;
sequence.Caption="sortnum";
sequence.ColumnName="count";
ds.Tables[0].Columns.Add(sequence);
for(int i=0;i<ds.Tables[0].Rows.Count;i++)
{
ds.Tables[0].Rows[i]["count"]=i+1;
}
DataView source=new DataView();
source=ds.Tables[0].DefaultView;
DataGrid1.DataSource=source;
DataGrid1.DataKeyField="BH";
DataGrid1.CurrentPageIndex=page_no;
DataGrid1.DataBind();
解决方案 »
- HBITMAP是什么意思?
- WPF DataGrid 动态绑定数据无效
- c# 中 有人知道不用javascript,仅凭代码可以判断浏览器javascript enable么?
- 关于将html代码保存为图片的问题
- DataGird改变单元格的颜色(webFrom)
- 弱弱的窗体关闭的问题
- 当网络有数据到达时,触发特定事件,该用什么来实现?
- 如何在表格中输入文字的时候保持不换行
- Web Form中的Calendar控件问题,很急,在线等~~~~
- c# 如何使主窗体前面显示一个窗体,不让点击主窗体,等主窗体的数据加载完成后,前面的窗体自动关闭
- 试问,传递值的方法有多少?
- 我在安装.net的时候,安装完之后,当打开.net的时候,出现
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %><script language="c#" runat="server">Double dblRunningTotal = 0;void Page_Load(Object sender,EventArgs e)
{
if (!Page.IsPostBack)
MyDataBind();
}void MyDataBind()
{
OleDbConnection objConnection;
OleDbCommand objCommand;
OleDbDataReader objDataReader;
String strSQLQuery; objConnection = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=\\\\premfsx\\sites\\premiumx\\xxxxxxx\\database\\northwind.mdb");
strSQLQuery = "Select ProductID,ProductName,UnitPrice,UnitsInStock FROM Products ORDER BY ProductID"; objCommand = new OleDbCommand(strSQLQuery, objConnection);
objConnection.Open(); // bind data to grid
MyDataGrid.DataSource = objCommand.ExecuteReader(CommandBehavior.CloseConnection);
MyDataGrid.DataBind(); // close db
objConnection.Close();}
void MyDataGrid_ItemDataBound(Object sender, DataGridItemEventArgs e)
{ if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
dblRunningTotal += (Double.Parse(e.Item.Cells[2].Text) * Double.Parse(e.Item.Cells[3].Text));
return;
}
if (e.Item.ItemType == ListItemType.Footer )
{
e.Item.Cells[2].Text="Total(Unit Price * Units in Stock)";
e.Item.Cells[3].Text = String.Format("{0:c}", dblRunningTotal);
}
}</script>
<html>
<body><h3><font face="Verdana">Total in DataGrid footer</font>
<span runat="server" id="MySpan"/></h3><form runat="server">
<ASP:DataGrid id="MyDataGrid" runat="server"
OnItemDataBound="MyDataGrid_ItemDataBound"
ShowFooter="True">
</ASP:DataGrid></form>
</body>
</html>
{
DataSet ds = CreateDataSet();
DataView dv = ds.Tables[0].DefaultView; int i = 1;
foreach(DataRowView drwv in dv)
{
drwv["RowID"] = i;
i += 1;
} dgList.DataSource = dv;
dgList.DataBind();
}
排序的列名>=DataGrid的最后一行的值(升序)
排序的列名<=DataGrid的最后一行的值(降徐)参见:ms-help://MS.VSCC/MS.MSDNVS.2052/cpref/html/frlrfSystemDataDataTableClassComputeTopic.htmms-help://MS.VSCC/MS.MSDNVS.2052/cpref/html/frlrfsystemdatadatacolumnclassexpressiontopic.htm