Scope of variables in aspx.cs file

后端 未结 6 2078
感情败类
感情败类 2021-01-29 04:15

I am writing following code:

namespace WebApplication5
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        private DataSet dataset1 = new Data         


        
6条回答
  •  执笔经年
    2021-01-29 05:04

    You don't get Data in the dataset in button2_click because button1_click and button2_clicks are entirely different requests to the server. And asp.net does not persists data stored in variables between requests. If you need to persist data you should use any State Management techniques provided by asp.net, like Session or Viewstate or Caching.

提交回复
热议问题