明细表2---浮动

<%@ Import Namespace="System.Data" %> <%@ Page language="c#" Codebehind="master_Detail2.aspx.cs" AutoEventWireup="false" Inherits="常用界面.master_Detail2" %> <script language=javascript> function hideAll() { var opc=document.getElementById("mGrid"); var dvArr=opc.getElementsByTagName("DIV"); var btArr=opc.getElementsByTagName("BUTTON"); var len=dvArr.length; for(var i=0;i

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data .SqlClient ;

namespace 常用界面
{
 /// <summary>
 /// master_Detail2 的摘要说明。
 /// </summary>
 public class master_Detail2 : System.Web.UI.Page
 {
  protected System.Data.SqlClient.SqlConnection sqlConnection1;
  protected System.Web.UI.WebControls.Repeater childRepeater;
  protected System.Web.UI.WebControls.DataGrid mGrid;
 
  private void Page_Load(object sender, System.EventArgs e)
  {
   // 在此处放置用户代码以初始化页面
   if(!Page.IsPostBack)
   {
    this.repeaterBind(true);
    //this.mGrid.Attributes["onclick"]="hideAll()";
   }
  }

  private void  repeaterBind(bool fr)
  {
   if(fr)
   {
    SqlCommand cmd=new SqlCommand("select EmployeeID,lastName,firstName,Address,City from  employees;select OrderID,EmployeeID,OrderDate,ShipName from  orders",this.sqlConnection1 );
    SqlDataAdapter da=new SqlDataAdapter(cmd);
    da.TableMappings.Add("Table","Emp");
    da.TableMappings.Add("Table1","Ord");
    DataSet ds=new DataSet("M_S");
    da.Fill(ds);
    ds.Relations.Add("Emp_Ord",ds.Tables["Emp"].Columns["EmployeeID"],ds.Tables["Ord"].Columns["EmployeeID"]);
       this.mGrid.DataSource=ds.Tables["Emp"].DefaultView ;
    this.mGrid .DataBind ();
    
   }
   else
   {
     DataSet dc=Cache["MD_Emp_Ord"] as DataSet ;
     this.mGrid.DataSource=dc.Tables["Emp"].DefaultView ;
     this.mGrid .DataBind ();
    
   }
  }
  private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
  {
   if(e.Item.ItemType==ListItemType.Item)
   {
    foreach(TableCell cl in e.Item.Cells )
    {
     cl.Attributes["valign"]="top";
    }
   }
  }
  #region Web 窗体设计器生成的代码
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
   //
   InitializeComponent();
   base.OnInit(e);
  }
  
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {   
   this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
   //
   // sqlConnection1
   //
   this.sqlConnection1.ConnectionString = "workstation id=DHZ;packet size=4096;integrated security=SSPI;data source=DHZ;pers" +
    "ist security info=False;initial catalog=Northwind";
   this.Load += new System.EventHandler(this.Page_Load);
   this.mGrid.ItemDataBound+=new DataGridItemEventHandler(this.DataGrid1_ItemDataBound );

  }
  #endregion
 }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值