如何在会话中获取dropdownlist选择的值

如何在会话中获取dropdownlist选择的值

本文介绍了如何在会话中获取dropdownlist选择的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在会话中为ddl选择值分配后,只是为了确保在运行模式下立即窗口中检查的会话值

但它没有花费ddl vale

session [ id]

当前上下文中不存在名称session

  protected   void  btnsaveProduct_Click( object  sender,EventArgs e)
{

尝试
{


con.Open();
Label1.Text = DropDownList1.SelectedValue;
会话[ id] = DropDownList1.SelectedValue;
SqlCommand cmd = new SqlCommand( rsa_products_sp_ProductTable ,con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue( @ Productname,txtProductName.Text);
cmd.Parameters.AddWithValue( @ ProductShortDescription,txtShortDescription.Text);
cmd.Parameters.AddWithValue( @ Productdescription,txtProductDescription.Text);
cmd.Parameters.AddWithValue( @ Price,txtPrice.Text);
cmd.Parameters.AddWithValue( @ MenuId,DropDownList1.SelectedItem.Value); >
请帮助我解决
解决方案

After assigning ddl selected value in session for just to make sure checked session value in immediate window in run mode
But it didn't take ddl vale
session["id"]
The name 'session' does not exist in the current context

protected void btnsaveProduct_Click(object sender, EventArgs e)
    {

                  try
     {


con.Open();
       Label1.Text = DropDownList1.SelectedValue;
       Session["id"] = DropDownList1.SelectedValue;
        SqlCommand cmd = new SqlCommand("rsa_products_sp_ProductTable", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@Productname", txtProductName.Text);
        cmd.Parameters.AddWithValue("@ProductShortDescription", txtShortDescription.Text);
        cmd.Parameters.AddWithValue("@Productdescription", txtProductDescription.Text);
        cmd.Parameters.AddWithValue("@Price", txtPrice.Text);
        cmd.Parameters.AddWithValue("@MenuId", DropDownList1.SelectedItem.Value);>
     Please Help me with this.
解决方案


这篇关于如何在会话中获取dropdownlist选择的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 21:55