Scope of variables in aspx.cs file

后端 未结 6 2173
感情败类
感情败类 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 04:57

    You need to have a look at Asp.net page life cycle, In your code when you click on your button page is destroyed and re created again and whole life cycle is followed and in that process your ds(dataset) is recreated too, therefore output xml doesn't have any data in it. To maintain state of your dataset have a look at State Management in Asp.net

提交回复
热议问题