简体   繁体   English

变量未在其他Web表单中使用

[英]variable not use in another webform

managing connection string on dropdown selection now the question is this "connection" object is not working in another webform because i need to use this connection on hole app using this connection object how to solve 现在在下拉选择中管理连接字符串的问题是此“连接”对象在另一个Web窗体中不起作用,因为我需要在使用此连接对象的Hole应用程序上使用此连接,如何解决

String connection = String.Empty;

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
    if (DropDownList1.SelectedItem.Text.Equals("RVL LOGISTICS (I) PVT LTD"))
    {
        connection = ConfigurationManager.ConnectionStrings["CompMasterConnectionString"].ConnectionString;
    }
    else if (DropDownList1.SelectedItem.Text.Equals("SIMONS SHIPPING PVT LTD"))
    {
        connection = ConfigurationManager.ConnectionStrings["DUM01ConnectionString"].ConnectionString;
    }
    else
    {
        DropDownList2.Enabled = false;
    }
}

Page state is not persistent: it goes out of memory once the page is rendered. 页面状态不是持久性的:页面呈现后它将耗尽内存。

You have to store the value elsewhere in order to reuse it. 您必须将值存储在其他位置才能重复使用。 Where you save it depends on where you want to use it. 保存位置取决于您要使用它的位置。

Some options: 一些选项:

  • Pass it through an URL. 通过URL传递它。 This might have security implications; 这可能会带来安全隐患;
  • View state; 查看状态;
  • Session object storage; 会话对象存储;
  • Application object storage. 应用程序对象存储。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM