How to Bind Data Table Results to String Variables

The .NET DataTable class lets you create a table of values within your .NET code without using a database. You store DataTable values in string fields, and you can use these fields to bind and store the data to a string variable in your Web page code. These variables can be used later in the code to display information for your users.

Instructions

    • 1

      Click the Windows "Start" button and select "All Programs." Click "Microsoft .NET Framework," then click "Visual Studio." Open the .NET project to load your software code.

    • 2

      Double-click the class file with your DataTable in Solution Explorer. The form opens in the VS designer. Right-click the form and select "View Code."

    • 3

      Create a variable to assign the DataTable value. The following code creates a variable for your .NET program:

      string myvar = string.Empty;

    • 4

      Bind the variable to a DataTable value. The following code assigns the first DataTable value to a variable:

      myvar = table.Tables[0].Row[0][0].ToString();

Related Searches:

References

Comments

Related Ads

Featured