for (int i=1;i<=5;i++) 

SqlCommand My_cmd=new SqlCommand("select * from adv_adv where adv_id="+i+"",Conn); 
Conn.Open(); 
SqlDataReader dr=My_cmd.ExecuteReader(); 
while(dr.Read()) 

AdStr_1=dr["adv_destine"].ToString; 
Label_i.Text=AdStr_1;//

dr.Close(); 
Conn.Close(); 


请教

解决方案 »

  1.   

    Label_i.Text=AdStr_1;//这句有问题error CS0246: 找不到类型或命名空间名称“Ad_i”(是否缺少 using 指令或程序集引用?)
      

  2.   

    for (int i=1;i<=5;i++) 

    SqlCommand My_cmd=new SqlCommand("select * from adv_adv where adv_id="+i+"",Conn); 
    Conn.Open(); 
    SqlDataReader dr=My_cmd.ExecuteReader(); 
    while(dr.Read()) 

    AdStr_1=dr["adv_destine"].ToString; 
    string aa=Label_+i.Tostring();
    Label aa=new Label();
    aa.Text=ADStr_1;

    dr.Close(); 
    Conn.Close(); 


      

  3.   


    for (int i=1;i<=5;i++) 

    SqlCommand My_cmd=new SqlCommand("select * from adv_adv where adv_id="+i+"",Conn); 
    Conn.Open(); 
    SqlDataReader dr=My_cmd.ExecuteReader(); 
    while(dr.Read()) 

    AdStr_1=dr["adv_destine"].ToString; 
    string aa="Label_"+i.Tostring();
    Label aa=new Label();
    aa.Text=ADStr_1;

    dr.Close(); 
    Conn.Close(); 

    }
      

  4.   

    出现错误拉?如下:1.“int”并不包含对“Tostring”的定义
    2.已在此范围定义了名为“aa”的局部变量。
    3.“string”并不包含对“Text”的定义
      

  5.   

    for (int i=1;i<=5;i++) 

    SqlCommand My_cmd=new SqlCommand("select * from adv_adv where adv_id="+i+"",Conn); 
    Conn.Open(); 
    SqlDataReader dr=My_cmd.ExecuteReader(); 
    while(dr.Read()) 

    AdStr_1=dr["adv_destine"].ToString; 
    Label aa=new Label();
    aa.Text=ADStr_1;

    dr.Close(); 
    Conn.Close(); 

    }
      

  6.   

    for (int i=1;i<=5;i++) 

    SqlCommand My_cmd=new SqlCommand("select * from adv_adv where adv_id="+i+"",Conn); 
    Conn.Open(); 
    SqlDataReader dr=My_cmd.ExecuteReader(); 
    while(dr.Read()) 

    AdStr_1=dr["adv_destine"].ToString; 

    Label lbl=Page.FindControl("Label_"+i.ToString());
    if(lbl!=null)
    lbl.Text=AdStr_1;  
    dr.Close(); 
    Conn.Close(); 


      

  7.   

    这样没有 i 这个循环参数
    如何取Label的值
      

  8.   

    出现如下错误error CS0029: 无法将类型“System.Web.UI.Control”隐式转换为“System.Web.UI.WebControls.Label”
      

  9.   

    for (int i=1;i<=5;i++) 

    SqlCommand My_cmd=new SqlCommand("select * from adv_adv where adv_id="+i+"",Conn); 
    Conn.Open(); 
    SqlDataReader dr=My_cmd.ExecuteReader(); 
    while(dr.Read()) 

    AdStr_1=dr["adv_destine"].ToString; 

    Label lbl=(Label)Page.FindControl("Label_"+i.ToString());
    if(lbl!=null)
    lbl.Text=AdStr_1;  
    dr.Close(); 
    Conn.Close(); 

    }
      

  10.   

    smilnet(笨笨) :
    多谢你,已经测试通过?