日期:2014-05-18  浏览次数:20784 次

datalist中嵌套datagrid问题,在线等待...
datalist中嵌套datagird,datagrid表只显示对应 "序号 "的行,例如:

-----------------
(datalist中:)
问题序号     问题描述      责任人
1                   未加盖公章   李丹
(datagrid中:)
问题序号 扣分标准   扣分
1    漏盖公章   2
1    审批环节违规 3
1    监管失利   1
-----------------
(datalist中:)
问题序号     问题描述      责任人
5                 缺少审批项   王五
(datagrid中:)
问题序号 扣分标准    扣分
5    手续不全    3
5    审批流程违规  2

代码如下:
private   void   Page_Load(object   sender,   System.EventArgs   e)
{
  if(!IsPostBack)
  {
SetBind();
                  SetBind1();
  }
}
private   void   SetBind()//绑定datalist
{
  String   Con   =   ConfigurationSettings.AppSettings[ "con "];
  SqlConnection   con   =   new   SqlConnection(Con);
  con.Open();
  SqlCommand   cmd=new   SqlCommand( "select   wt_no   from   wt_shezhi   where   xm_no= ' "+L5.Text.Trim()+ " ' ",   con);
  SqlDataReader   g=cmd.ExecuteReader();
  if(g.Read())
{
  a=g[ "wt_no "].ToString(); }
  g.Close();
      con.Close();
  SqlDataAdapter   da=new   SqlDataAdapter();
  da.SelectCommand   =   new   SqlCommand( "select   *   from   wt_shezhi   where   xm_no= ' "+L5.Text.Trim()+ " ' ",   con);
  DataSet   ds=new   DataSet();
  da.Fill(ds, "table1 ");
  this.DataList1.DataSource=ds.Tables[ "table1 "];
  this.DataList1.DataBind();
}
private   void   SetBind1()//绑定datagrid
{
  for(int   i=0;i <DataList1.Items.Count;i++)
  {
                  DataGrid   DG1=(DataGrid)this.DataList1.Items[i].FindControl( "DG1 ");
String   Con   =   ConfigurationSettings.AppSettings[ "con "];
SqlConnection   con   =   new   SqlConnection(Con);
SqlDataAdapter   da=new   SqlDataAdapter();
       da.SelectCommand   =   new   SqlCommand( "select   *   from   kf_shezhi   where   wt_no= ' "+a.Trim()+ " ' ",   con);
DataSet   ds=new   DataSet();
da.Fill(ds, "table1 ");
DG1.DataSource=ds.Tables[ "table1 "];
DG1.DataBind();

        }
}
但是每个datagrid中显示的是所有 "序号 "的行,不是和datalist相对应 "序号 "的行.
请帮忙...

------解决方案--------------------
在HTML里面的代码:
<asp:repeater id= "Repeater1 " runat= "server ">
<ItemTemplate>
<h2> <%# DataBinder.Eval(Container.DataItem, "CategoryName ") %> </h2>
<asp:DataGrid Runat =server DataSource = ' <%# FilterDate(DataBinder.Eval(Container.DataItem, "CategoryID ")) %> ' ID= "Datagrid1 "/>
</ItemTemplate>
</asp:repeater>
在.cs里面的代码:
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面

if(!this.IsPostBack)
{
//DataView DV= MyD


MyDS= new DataSet(); <