列子:
string DataName = Request.QueryString["data"].ToString();

switch(DataName){
case "-1":
//合同付款
jh_htfk.jh_ht _htfk = new jh_htfk.jh_ht();
ListDataGrid.DataSource = _htfk.getDropListOfHT();
break;
case "1":
jh_htfk.jh_ht _htfk1 = new jh_htfk.jh_ht();
DataView thisView = new DataView(_htfk1.getDropListOfHT().Tables[0]);
ListDataGrid.DataSource = thisView;
break;
case "ht":
//合同信息
jh_ht.jh_ht jhht = new jh_ht.jh_ht();
DataView thisView1 = new DataView(jhht.get_jhht_ds_grid(Session["GCBH"].ToString()).Tables[0]);
ListDataGrid.DataSource = thisView1;
break;
}
string[] thisRQ = Request.QueryString["Rz"].ToString().Split(',');
for(int i=0;i<thisRQ.Length;i++){
BoundColumn MyAddItem = new BoundColumn();
MyAddItem.DataField = thisRQ[i].ToString().Replace(" none","");
if(thisRQ[i].ToString().Replace("none","") != thisRQ[i].ToString()){
MyAddItem.ItemStyle.CssClass = "Nones";
}
ListDataGrid.Columns.AddAt(0,MyAddItem);
ListDataGrid.DataBind();
}

解决方案 »

  1.   

    可否针对我的疑问,说的详细一点,我该如何给DataGrid模板中的Label赋值?
      

  2.   

    你可以不用for
    你用一用while试一试
    while(DataReader.Read())
    {
       Label1.Text=DataReader.Table["字段名"].ToString();
       Label2.Text=DataReader.Table["字段名"].ToString();
       ......}
    这样可以查询到所有纪录
      

  3.   

    不要Label了, 干么搞个label啊
      

  4.   

    那该如何显示数据呢? <% %>? 请指点
      

  5.   

    我做好了,还是用Label ,用复杂绑定就可以了。