ViewState的在我的向导 [英] ViewState in my Wizard

查看:135
本文介绍了ViewState的在我的向导的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个向导从我的组织加入的雇员。在第一步,我有几个控件,其中一个是的EmpID(PK)。问题到达第二步,在那里我只有一个控制是DropDownList1这是从数据源绑定(code-后面)。我想从previous步骤DropDownList1和的EmpID的这个值将其插入到被称为dbo.Emp_Skills另一个表。

I have a Wizard to Add an Employee from my org. In Step1, I have few controls, one of them is EmpID (PK). The problem arrives in Step2, where I have only one control that is DropDownList1 which is binded from Datasource (code-behind). I want this value of DropDownList1 and EmpID from previous Step to insert it into another table called 'dbo.Emp_Skills'.

dbo.Emp_skills'表有2列:

'dbo.Emp_skills' table has 2 columns:

的EmpID(FK)| SkillID(FK)

EmpID (FK) | SkillID (FK)

我要如何插入的EmpID值到这个表的时候是不是实际保存呢?
我可以把连接后,只需插入我的DropDownList像这样的值。

How do I insert value of EmpID into this table when it is not actually saved? I can simply insert value of my DropDownList like this after my connections..

cmd.Parameters.AddWithValue("@SkillID", DropDownList1.SelectedValue);

但我怎么插入的EmpID到表?
的EmpID和CertID都FK在dbo.Emp_Cert ..这将是一个问题?

But how do I insert the EmpID into the table? EmpID and CertID are both FK in the dbo.Emp_Cert.. Will it be a problem??

我用的ViewState在Page_Load中这样的 -

I have used ViewState in Page_Load like this-

好吧,我已经使用了简单的ViewState这样的事 -

Well I have used simple ViewState something like this-

 if(ViewState["NameOfUser"] != null)
            NameLabel.Text = ViewState["NameOfUser"].ToString();
        else
            NameLabel.Text = "Not set yet...";


我用的Label1控制向导的步骤2。


I used Label1 Control in Step2 of Wizard.

protected void Wizard1_NextButtonClick(object sender, WizardNavigationEventArgs e)
        {
            ViewState["NameOfUser"] =  TextBox1.Text;
            NameLabel.Text = TextBox1.Text;

        }

然后我用于插入 -

And then I used to insert that-

cmd.Parameters.AddWithValue("@EmpID", TextBox1.Text);
cmd.Parameters.AddWithValue("@SkillID", DropDownList1.SelectedValue);

但它不工作。

推荐答案

假设你正在使用asp.net向导控制,你的TextBox1中仍然存在的页面上,你可以访问它的值。

Assuming you are using asp.net wizard control, your TextBox1 is still there on the page, and you can access its value.

这是可行的。

cmd.Parameters.AddWithValue("@SkillID", DropDownList1.SelectedValue);
cmd.Parameters.AddWithValue("@EmpID", TextBox1.Text);

这篇关于ViewState的在我的向导的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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