帮忙看下哪有语法错误~
创建DataRelation对象来表示数据库中的两个关系,代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text; //用于字符串处理
using System.Data.SqlClient; //用于数据处理等
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
UpdateDetailsGrid( );
DataSet ds = CreateDataSet( );
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind( );
//创建DataView,并将其绑定到GridView
DataView detailsView = new DataView(ds.Tables[1]);
DetailsGridView.DataSource = detailsView;
Session[ "DetailsView "] = detailsView;
DetailsGridView.DataBind( );
//将OrderRelationsGridView绑定到关系集合
OrderRelationsGridView.DataSource = ds.Relations;
OrderRelationsGridView.DataBind( );
}
}
//获取订单细节
public void OnSelectedIndexChangedHandler(object sender, EventArgs e)
{
UpdateDetailsGrid( );
}
private void UpdateDetailsGrid( )
{
int index = GridView1.SelectedIndex;
if (index != -1)
{
//从GridView中获取订单号