Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 251
  • Last Modified:

How do I add a dataset to ViewState

Right now I have this code.

private void BindTextBoxes()
            {
      this.txt_fname.Text=CustomerGridData.Tables["t_customers"].Columns"customer_fname"].ToString();
            }

But I get this error at run time

Object reference not set to an instance of an object.  I think ViewState is the answer but I'm not sure how to add a dataset to ViewState.

Thanks,
Sean
0
sean-keys
Asked:
sean-keys
1 Solution
 
praneethaCommented:
 this.txt_fname.Text=CustomerGridData.Tables["t_customers"].Columns"customer_fname"].ToString();

r u missing [ after Columns
0
 
sean-keysAuthor Commented:
private void BindTextBoxes()
            {
                  this.txt_fname.Text=CustomerGridData.Tables["t_customers"].Columns["customer_fname"].ToString();
            }



That’s the actual code, not the debug output.


0
 
RamuncikasCommented:
Hey, Sean.

I know VB.NET better than C# but i think it will be easy to understand:

To store data into ViewState use this:
Me.Viewstate("t_customers")=CustomerGridData.Tables("t_customers")

To retrieve what you have stored use this:
Dim T_Customers as New DataTable
T_Customers=CType(Me.Viewstate("t_customers"), DataTable)

Hope this will help
Good luck
Ramuncikas
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now