Scope of variables in aspx.cs file

后端 未结 6 2079
感情败类
感情败类 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条回答
  •  闹比i
    闹比i (楼主)
    2021-01-29 05:14

    I suggest please use ViewState as Session will consume lot of server memory, though you can use any one of them to solve the purpose.

    I don't think button1's event handler is doing anything apart from creating ds. So only one event handler will solve the purpose.

    Another way to access ds in both the event handlers without losing data is declare ds as static. But this mechanism does not suit this scenario.

提交回复
热议问题