业务层:这里chexingid得到是存储过程返回的值
  public static bool CreateCheXing(string chexinghao, string sucheng, string description, string imagefilename, string tuijian, string leibieid)
    {
        SqlCommand comm = GenericDataAccess.CreateCommand();
        comm.CommandText = "CreateCheXing";
        SqlParameter param = comm.CreateParameter();
        param.ParameterName = "@CheXingHao";
        param.Value = chexinghao;
        param.SqlDbType = SqlDbType.VarChar;
        comm.Parameters.Add(param);
        param = comm.CreateParameter();
        param.ParameterName = "@SuCheng";
        param.Value = sucheng;
        param.SqlDbType = SqlDbType.VarChar;
        param.Size = 50;
        comm.Parameters.Add(param);
        param = comm.CreateParameter();
        param.ParameterName = "@Descrition";
        param.Value = description;
        param.SqlDbType = SqlDbType.VarChar;
        param.Size = 5000;
        comm.Parameters.Add(param);
        param = comm.CreateParameter();
        param.ParameterName = "@ImageFileName";
        param.Value = imagefilename;
        param.SqlDbType = SqlDbType.VarChar;
        param.Size = 50;
        comm.Parameters.Add(param);
        param = comm.CreateParameter();
        param.ParameterName = "@TuiJian";
        param.Value = tuijian;
        param.SqlDbType = SqlDbType.Bit;
        comm.Parameters.Add(param);
        param = comm.CreateParameter(); ;
        param.ParameterName = "LeiBieID";
        param.Value = leibieid;
        param.SqlDbType = SqlDbType.Int;
        comm.Parameters.Add(param);
        comm.Parameters.Add("@CheXingID", SqlDbType.Int).Direction = ParameterDirection.Output;
        int chexingid;
        int result = -1;
        try
        {
            result = GenericDataAccess.ExecuteNonQuery(comm);
            chexingid = (int)comm.Parameters["@CheXingID"].Value;
        }
        catch (Exception ex)
        {
            Utilities.LogError(ex);
            throw ex;
        }
        return (result != -1);
    }表示层:我要在一个default.aspx 里如下事件里用到这个chexingid的值 问 如何读取他的值呢?
  protected void Button1_Click(object sender, EventArgs e)
    {
         public static int CreateMuLu(int chengci, string xiangmuhao, string xiangmuname, int chexingid)
    {
    }

解决方案 »

  1.   

    你的chexingid在那个函数中是局部变量,所以外部不能访问
    把它变成页面变量吧
      

  2.   

     protected void Button1_Click(object sender, EventArgs e) 
        { 
           int sde=CreateMuLu(int chengci, string xiangmuhao, string xiangmuname, int chexingid) ;
        
        }
      

  3.   

    在参数里加个input n  看行不行
      

  4.   

      protected void Button1_Click(object sender, EventArgs e)
        {        if (Page.IsValid)
            { 
                    
              if (_upmulu == _chexinghao)
                {
                    _sucheng = suchengTextBox.Text;
                    _description = descriptionTextBox.Text;
                    _tuijian = tuijianCheckBox.Checked.ToString();
                    bool success = CatalogAccess.CreateCheXing(_upmulu, _sucheng, _description, _upimage, _tuijian, leibieid);
                    createCheLabel.Text = success ? "添加车型成功" : "添加车型失败";
                    //要在下面用到存储过程的返回值chexingid
                    chengci=...
                    xianguhao=...
                    xiangmuname=...
                    chexingid=      //这个得到的是存储过程的返回值 该如何读取
                    bool success2=createMuLu(chengci,xiangmuhao,xiangmuname,chexingid)                 
                    chexinghaoTextBox.Text = string.Empty;
                    suchengTextBox.Text = string.Empty;
                    descriptionTextBox.Text = string.Empty;
                }
                else
                {
                    createCheLabel.Text = "输入的车型号更上传的车型号不一致!没有添加";
                }
              }