Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8172543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:48:59+00:00 2026-06-06T21:48:59+00:00

my question is, if it is possible that the button_2 can call/use the data

  • 0

my question is, if it is possible that the button_2 can call/use the data save in the datatable create in button_1. let say

void Button1_Click(Object sender, EventArgs e)
{
  //some code to fill the datatable
}  

now button 1 code has been done and it works, the only problem i have is i have no idea how to send de datatable from button_1 to button_2 this way button_2 can use the same data store in the datatable, by the way i am using C#, asp.net, and NOT using Visual Studio.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T21:49:01+00:00Added an answer on June 6, 2026 at 9:49 pm

    Since you state that the data is fetched in the event handler for Button1 and it should be available in the event handler from Button2, you will have to persist the datatable in way so that it survives post backs.

    There are several possibilities:

    • Viewstate (as long as the object is Serializable, for DataTable it seems to work)
    • Session (if you use sessions)
    • Application scope (Application[“yourKeyName”] = dbTable;)
    • Static member of suitable class
    • Server cache

    Or, if the database operation to fetch the data is not “heavy” you could just load it from there when you need it.

    For more reading regarding state management, see

    http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx

    Edit: To give you a more specific recommendation. Try storing the DataTable in the Session, like this

    Session["preBuiltDataTable"] = theTable;
    

    at the end of Button1_Click. Then get a reference to it using

    DataTable tableFromB1Click = Session["preBuiltDataTable"] as DataTable;
    if (tableFromB1Click != null)
    {
        // do stuff here
    }
    

    in Button2_Click.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It's possible that this question has already been asked, but I can't seem to
My question has two parts: Is it possible that, if a segfault occurs after
This is more of a cryptography theory question, but is it possible that the
Question Is it possible to stop a Message Driven Bean (programmatically), so that it
Question: Is is possible, with regex, to match a word that contains the same
A Castle Windsor question: Is it possible to register a class that has an
Question 1: Is is possible to throw an exception that will not be caught
Possible Duplicate: Rewriting URL that contains question mark Hi a noob question for url
Possible Duplicate: String comparison in Objective-C I realize that the question is not very
Following this question, it seems that it is possible to open a file from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.