Professional Web Applications Themes

dataset can not be shared across subs - ASP.NET General

Hi, I declared a dataset outside any subs, then I fill the dataset with a tables in a Private Sub1, then I want to take the data out from the dataset in Sub2. like . sub2() datagrid.datasource=ds.tables("t").defautview datagrid.databind() end sub but it goes wrong. if I show the tables the datagrid in the sub where the dataset is fill with SQLdataAdapter, it is OK. I remmebered dataset is in memory, can I shared the dataset in different Subs? thanx. Nakhi Lijiang,Yunnan,China...

  1. #1

    Default dataset can not be shared across subs

    Hi,
    I declared a dataset outside any subs, then I fill the dataset with a
    tables in a Private Sub1, then I want to take the data out from the dataset
    in Sub2.
    like .
    sub2()
    datagrid.datasource=ds.tables("t").defautview
    datagrid.databind()
    end sub

    but it goes wrong. if I show the tables the datagrid in the sub where the
    dataset is fill with SQLdataAdapter, it is OK.

    I remmebered dataset is in memory, can I shared the dataset in different
    Subs?

    thanx.
    Nakhi
    Lijiang,Yunnan,China


    nakhi Guest

  2. #2

    Default Re: dataset can not be shared across subs

    remember the web is stateless so as soon as you post back from the server
    your data is gone which is why it doesn't work outside of the sub. what you
    will need to do is hold the data somewhere and get it when you need to
    consider
    Session["STORE"] = ds from sub 1
    in sub 2
    DataSet ds = new DataSet();
    if(Session["STORE"] != null)
    ds = (DataSet)Session["STORE"];
    "nakhi" <com> wrote in message
    news:phx.gbl... 
    dataset 


    Alvin Guest

  3. #3

    Default Re: dataset can not be shared across subs

    thanx,I filled the dataset in Sub Page_load(), so it is run in every
    request, and I can share the dataset in any subs.

    Nakhi

    "Alvin Bruney" <com> 写入邮件
    news:phx.gbl... 
    you 
    > dataset [/ref]
    the [/ref]
    different 
    >
    >[/ref]


    nakhi Guest

Similar Threads

  1. Calling subs
    By Werner in forum PERL Beginners
    Replies: 4
    Last Post: June 10th, 11:30 AM
  2. ref's to subs
    By mgoland@optonline.net in forum PERL Beginners
    Replies: 11
    Last Post: November 5th, 11:19 PM
  3. Replies: 2
    Last Post: October 31st, 02:43 AM
  4. Tracing Subs
    By Sharad Gupta in forum PERL Beginners
    Replies: 4
    Last Post: August 9th, 04:57 PM
  5. Help w/ LoadViewState and SaveViewState subs
    By Showjumper in forum ASP.NET General
    Replies: 0
    Last Post: June 26th, 01:38 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139