使用Session将值从一个表单传递到下一个表单 [英] passing values from one form to next with Session

查看:115
本文介绍了使用Session将值从一个表单传递到下一个表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i我试图将从前一页传递的id值插入到当前页面但是它给出了null异常。

我的代码如下: br />
.cs文件:


i am trying to insert id value passing from previous page to current page but it''s giving null exception.
my code is as follow:
.cs file:

protected void btnAdd_Click(object sender, EventArgs e)
   {
       if (objTimberDetails.Insert(Convert.ToInt64(Session["Carting_Challan_ID"].ToString()),
                                   Convert.ToInt32(ddlSpecies.SelectedValue),
                                   txtJungle_no.Text.Trim(),
                                   Convert.ToDouble(txtcoupe_length),
                                   Convert.ToDouble(txtcoupe_girth),
                                   Convert.ToDouble(txtcoupe_cubicmeter),
                                   txtDepot_No.Text.Trim(),
                                   Convert.ToDouble(txtDepot_length),
                                   Convert.ToDouble(txtDepot_girth),
                                   Convert.ToDouble(txtDepot_cubicmeter),
                                   Convert.ToDouble(txtDifference_cubicmeter),
                                   Convert.ToInt32(Session["OfficeID"].ToString())))
       {
           lblStatus.Text = Resources.Language.Common_Record_Add;
       }
       BindGrid(Session["Language"].ToString());





business

逻辑文件:



business
logic file:

public clsTimberDetails()
       {
       }
       public bool Insert(long Carting_Challan_ID,
                          int Species_Id,
                          string Jungle_no,
                          double coupe_length,
                          double coupe_girth,
                          double coupe_cubic_meter,
                          string Depot_No,
                          double Depot_length,
                          double Depot_girth,
                          double Depot_cubicmeter,
                          double Difference_cubicmeter,
                          int DIV_ID)
       {
           bool res = false;
           System.Collections.ArrayList sel = new System.Collections.ArrayList();

           sel.Add("SP_trn_TimberD_Insert");
           ArrayList lstParam = new System.Collections.ArrayList();

           SqlParameter param;

           param = new SqlParameter();
           param.ParameterName = "@Carting_Challan_ID";
           param.SqlDbType = SqlDbType.BigInt;
           param.Value = Carting_Challan_ID;
           lstParam.Add(param);


           param = new SqlParameter();
           param.ParameterName = "@Species_Id";
           param.SqlDbType = SqlDbType.Int;
           param.Value = Species_Id;
           lstParam.Add(param);

           param = new SqlParameter();
           param.ParameterName = "@Jungle_no";
           param.SqlDbType = SqlDbType.NVarChar;
           param.Value = Jungle_no;
           lstParam.Add(param);

           param = new SqlParameter();
           param.ParameterName = "@coupe_length";
           param.SqlDbType = SqlDbType.Float;
           param.Value = coupe_length;
           lstParam.Add(param);


           param = new SqlParameter();
           param.ParameterName = "@coupe_girth";
           param.SqlDbType = SqlDbType.Float;
           param.Value = coupe_girth;
           lstParam.Add(param);

           param = new SqlParameter();
           param.ParameterName = "@coupe_cubic_meter";
           param.SqlDbType = SqlDbType.Float;
           param.Value = coupe_cubic_meter;
           lstParam.Add(param);


           param = new SqlParameter();
           param.ParameterName = "@Depot_No";
           param.SqlDbType = SqlDbType.NVarChar;
           param.Value = Depot_No;
           lstParam.Add(param);

           param = new SqlParameter();
           param.ParameterName = "@Depot_length";
           param.SqlDbType = SqlDbType.Float;
           param.Value = Depot_length;
           lstParam.Add(param);

           param = new SqlParameter();
           param.ParameterName = "@Depot_girth";
           param.SqlDbType = SqlDbType.Float;
           param.Value = Depot_girth;
           lstParam.Add(param);

           param = new SqlParameter();
           param.ParameterName = "@Depot_cubicmeter";
           param.SqlDbType = SqlDbType.Float;
           param.Value = Depot_cubicmeter;
           lstParam.Add(param);

           param = new SqlParameter();
           param.ParameterName = "@Difference_cubicmeter";
           param.SqlDbType = SqlDbType.Float;
           param.Value = Difference_cubicmeter;
           lstParam.Add(param);


           param = new SqlParameter();
           param.ParameterName = "@DIV_ID";
           param.SqlDbType = SqlDbType.Int;
           param.Value = DIV_ID;
           lstParam.Add(param);

           res = new eAuctionDAL.SQLDAL().UpdateTransData(sel, lstParam, false);
           return res;

       }







在我的sql表中我有还有一个字段是这个表的ID,它是自动递增的字段



这个代码有什么问题

请帮助。< br $> b $ b



谢谢




in my sql table i have one more field which is this table''s ID which is auto incremented field

what is wrong in this code
pls help.


thanks

推荐答案

添加两个临时变量并设置断点第一行。



Add two temporary variables and set a breakpoint at the first line.

protected void btnAdd_Click(object sender, EventArgs e)
{
string CartingChallanID = Session["Carting_Challan_ID"].ToString();
string OfficeID = Session["OfficeID"].ToString();
//your code
}





我确定其中一个变量是罪魁祸首。



I am sure one of these variables is the culprit.


这篇关于使用Session将值从一个表单传递到下一个表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆