添加TextBox的时候ID对应的是TextBox1吗?

解决方案 »

  1.   

    ((TextBox)datagrid.Items[i].FindControl("TextBox1")).Text
    这样呢?
      

  2.   

    to acewang(龍芯*Inside!)
    是TextBox1啊
      

  3.   


    string d6="select "+r1+".zkzprq0,zmzd.description," + r1 + ".zkfzdbm,count(*) from zmzd," + r1 + " where ( "+r1+".zkfzdbm=zmzd.unit) and ( "+r1+".zkzprq0='"+d2+"')  group by "+r1+".zkzprq0,zmzd.description,"+r1+".zkfzdbm ";
    string d7="select fj18d.data_date_view.d18_date,zmzd.unit,fj18d.data_date_view.entry002,zmzd.description from zmzd,fj18d.data_date_view  where ( zmzd.unit=fj18d.data_date_view.unit) and (fj18d.data_date_view.report_name='XB2') and ( fj18d.data_date_view.d18_date='"+d2+"')";
    OleDbConnection myConnection =new OleDbConnection("Provider=MSDAORA;Password=hpadmin;User ID=hpadmin;Data Source=ora18d");
    myConnection.Open();
    DataSet myDataset=new DataSet();
    OleDbDataAdapter myAdapter=new OleDbDataAdapter(d6,myConnection);
                    OleDbDataAdapter myAdapter1=new OleDbDataAdapter(d7,myConnection);
    myAdapter.Fill(myDataset,"z1"); 
    myAdapter1.Fill(myDataset,"z2"); 
    int count1 = myDataset.Tables["z1"].Rows.Count;
                    int count2 = myDataset.Tables["z2"].Rows.Count;
    dt1=myDataset.Tables["z1"];
    dt2=myDataset.Tables["z2"];
    string del1="delete from hpcx where ( d18_date='"+d2+"')";
    string del2="delete from sbdcx where ( d18_date='"+d2+"')";
    //删除货票入库数据
                    OleDbCommand inst1 = new OleDbCommand (del1,myConnection);
                    inst1.ExecuteNonQuery();
    //删除十八点入库数据
    OleDbCommand inst2 = new OleDbCommand (del2,myConnection);
    inst2.ExecuteNonQuery();
                    //货票入库
    while(i<count1)
    {
    string dtt1=dt1.Rows[i][0].ToString();
    string dtt2=dt1.Rows[i][2].ToString();
    int dtt3=int.Parse(dt1.Rows[i][3].ToString());
    string dtt4=dt1.Rows[i][1].ToString();
    string d9="insert into hpcx values ('"+dtt1+"','"+dtt2+"',"+dtt3+",'"+dtt4+"')";
    OleDbCommand inst = new OleDbCommand (d9,myConnection);
    inst.ExecuteNonQuery() ;
            i++;
    }
                    //string rk="select * from hpcx where ( d18_date='"+d2+"')";
                    //OleDbDataAdapter myAdapter1=new OleDbDataAdapter(rk,myConnection);
    //myAdapter1.Fill(myDataset,"rk");  DataGrid1.AutoGenerateColumns = false; BoundColumn col = new BoundColumn();
    col.HeaderText="站 名"; 
    col.DataField="description";
    DataGrid1.Columns.Add(col);  // Create Name column & add to DataGrid
    col = new BoundColumn();
    col.HeaderText="站名略码"; 
    col.DataField="zkfzdbm";
    DataGrid1.Columns.Add(col); 
    // Create Name column & add to DataGrid
    col = new BoundColumn();
    col.HeaderText="装车总数"; 
    col.DataField="count(*)";
    DataGrid1.Columns.Add(col); 
    // Create Name column & add to DataGrid
    DataGrid1.DataSource=myDataset.Tables["z1"].DefaultView;
    DataGrid1.DataBind();
     Label1.Text=d2+"入库成功!!!";
      

  4.   

    Page_Load里面怎么写的,不要放在if (!IsPostBack)里面
      

  5.   

    首先要判断一下datagrid.Items[i].ItemType,只有是数据行的时候才有效,Header和Footer不行
      

  6.   

    Page_Load里面怎么写的,不要放在if (!IsPostBack)里面如果不放到if (!IsPostBack)里,我点击一个button的时候不是又初始化一次吗,那我上次输入的数据不就没了吗?
      

  7.   

    ((TextBox)datagrid.Items[i].Cells[j].FindControl("TextBox1")).Text
    测一下 i和j的值    
    这句话肯定没问题!!
      

  8.   

    好了,问题解决了,果然是if (!IsPostBack)在作怪,谢谢大家了,结贴