程序如下:
public partial class MaterialChange : System.Web.UI.Page
{
    SqlConnection MyConnection = new SqlConnection(@"Data Source=MICROSOF-F32539\SQLEXPRESS;Initial Catalog=WZGL;Integrated Security=True");
    string mid = "";
    string tempid = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        String id = Request.QueryString["uid"].ToString();
        tempid = id;
        String materialid = Request.QueryString["mid"].ToString();
        String mainstorehousename = Request.QueryString["mname"].ToString();
        String storehousename = Request.QueryString["sname"].ToString();
        string aid = id.ToString().Substring(2, 36);
        string man = mainstorehousename;
        string stn = storehousename;
        string maid = materialid;
        //Response.Write(man + stn + maid);
        if (Session["userLogin"].ToString() != "true")
        {
            Response.Redirect("Login.aspx");
        }
        Contents en = new Contents();
        en.GetMenu(uMenu, id, MyConnection);
        GetMsg(maid,man,stn);
    }
    public void GetMsg(string c, string mn, string sn)
    {
        try
        {
            if (MyConnection.State.ToString().Equals("Close"))
            {
                MyConnection.Open();
            }
            SqlCommand MyCommand = MyConnection.CreateCommand();
            MyCommand.CommandText = "SELECT * FROM Material INNER JOIN MaterialType ON Material.materialTypeID = MaterialType.materialTypeID INNER JOIN Unit ON Material.unitID = Unit.unitID INNER JOIN Material_SecondStoreHouse ON Material.materialID = Material_SecondStoreHouse.materialID INNER JOIN SecondStoreHouse ON Material_SecondStoreHouse.storehouseID = SecondStoreHouse.storehouseID INNER JOIN FirstStoreHouse ON SecondStoreHouse.mainstorehouseID = FirstStoreHouse.mainstorehouseID where materialCode = '" + c + "' and mainstorehouseName = '" + mn + "' and storehouseName = '" + sn + "'";
            SqlDataAdapter objAdapter = new SqlDataAdapter(MyCommand);
            DataSet ds = new DataSet();
            objAdapter.Fill(ds, "NewMsg");            if (ds.Tables["NewMsg"].Rows.Count > 0)
            {
                TextBoxCode.Text = c;
                TextBoxMask.Text = ds.Tables["NewMsg"].Rows[0]["materialMask"].ToString();
                TextBoxPrice.Text = ds.Tables["NewMsg"].Rows[0]["unitPrice"].ToString();
                string unitname = ds.Tables["NewMsg"].Rows[0]["unitName"].ToString();
                string mtype = ds.Tables["NewMsg"].Rows[0]["type"].ToString();
                string zkn = ds.Tables["NewMsg"].Rows[0]["mainstorehouseName"].ToString();
                string ejkn = ds.Tables["NewMsg"].Rows[0]["storehouseName"].ToString();
                mid = ds.Tables["NewMsg"].Rows[0]["materialID"].ToString();
                //string pid = ds.Tables["NewMsg"].Rows[0]["pictureID"].ToString();                GetUnit(unitname);
                GetType(mtype);
                GetSecond(ejkn);
                GetMainName(zkn);                //ImageButtonPicture.PostBackUrl = "MaterialPicture.aspx?id=" + pid + "";
            }        }
        catch (Exception e)
        {
            Response.Write(e.Message);
        }
        finally
        {
            MyConnection.Close();
        }
    }
..........    
    public void UpdateMaterial(string m, string tid, string unid, string up)
    {
        try
        {
            MyConnection.Open();
            //SqlCommand MyCommand = MyConnection.CreateCommand();
            string sql = "Update Material set materialMask = '" + m + "', materialTypeID = '" + tid + "', unitID = '" + unid + "', unitPrice = '" + up + "' where materialID = '" + mid + "'";
            SqlCommand MyCommand = new SqlCommand(sql, MyConnection);
            //MyCommand.CommandText = "Update Material set materialMask = '" + m + "', materialTypeID = '" + tid + "', unitID = '" + unid + "', unitPrice = '" + up + "' where materialID = '" + mid + "'";
            //Response.Write(MyCommand.CommandText);
            SqlDataAdapter objAdapter = new SqlDataAdapter(MyCommand);
            MyCommand.ExecuteNonQuery();
            //objAdapter.UpdateCommand = MyCommand;
            //DataSet ds = new DataSet();
            //objAdapter.Fill(ds, "Material");
            //objAdapter.Update(ds, "Material");
            //ds.AcceptChanges();            Response.Write("<script>alert('物资表修改成功!')</script>");
        }
        catch (Exception fsid)
        {
            Response.Write(fsid.Message);
        }
        finally
        {
            MyConnection.Close();
        }
    }
    public void UpdateMaterial_Second(string sid)
    {
        try
        {
            MyConnection.Open();
            string sql1 = "Update Material_SecondStoreHouse set storehouseID = '" + sid + "' where materialID = '" + mid + "'";
            SqlCommand MyCommand = new SqlCommand(sql1,MyConnection);
            MyCommand.ExecuteNonQuery();
            //SqlCommand MyCommand = MyConnection.CreateCommand();
            //MyCommand.CommandText = "Update Material_SecondStoreHouse set storehouseID = '" + sid + "' where materialID = '" + mid + "'";
            //SqlDataAdapter objAdapter = new SqlDataAdapter(MyCommand);
            //SqlCommandBuilder builder = new SqlCommandBuilder(objAdapter);
            //DataSet ds = new DataSet();
            //objAdapter.Fill(ds, "UpdateMaterial_Second");
            //objAdapter.Update(ds, "UpdateMaterial_Second");            Response.Write("<script>alert('中间表修改成功!')</script>");
        }
        catch (Exception fsid)
        {
            Response.Write(fsid.Message);
        }
        finally
        {
            MyConnection.Close();
        }
    }
    protected void ButtonConfirm_Click(object sender, EventArgs e)
    {
        //string code = "";
        string type = "";
        string mainstore = "";
        string secondstore = "";
        string price = "";
        string mask = "";
        string unit = "";
        string newunitid = "";
        string newtypeid = "";
        string newmainid = "";
        string newsecondid = "";        //code = TextBoxCode.Text;
        mask = TextBoxMask.Text;
        price = TextBoxPrice.Text;
        Response.Write(price);
        mainstore = DropDownListMainStore.SelectedItem.Text;
        secondstore = DropDownListSecondStore.SelectedItem.Text;
        type = DropDownListType.SelectedItem.Text;
        unit = DropDownListUnit.SelectedItem.Text;        newunitid = SearchUnit(unit);
        newtypeid = SearchMaterialTypeID(type);
        newmainid = SearchFirstStoreID(mainstore);
        newsecondid = SearchSecondStoreID(secondstore,newmainid);
        UpdateMaterial(mask,newtypeid,newunitid,price);
        UpdateMaterial_Second(newsecondid);        Response.Write("<script>alert('物资修改成功!')</script>");
        Response.Write("window.location.replace( 'MaterialDeleteAndChange.aspx?uid=" + tempid + "'); ");
    }
    protected void ImageButtonPicture_Click(object sender, ImageClickEventArgs e)
    {
        string mcode = "";        mcode = TextBoxCode.Text;        Response.Redirect("MaterialPicture.aspx?code=" + mcode + "");
    }
}(我在page_load中获取上一页的值然后赋值给该页从而显示就信息,用户输入并修改好,按按钮更新信息,但发现获取不了新值)