How To Access a Column Field in a Grid View

An ASP.NET GridView control displays a list of data to your readers. You must be able to identify the selected cell in the GridView. Use the "SelectedItem" property to access a column field's value in the the grid. You can use the value to calculate additional data, or display the column's data to the user in a message box or another Web page.

Instructions

    • 1

      Click the Windows "Start" button and select "All Programs." Click "Microsoft .NET Framework," then click "Visual Studio." Open your ASP.NET project after Visual Studio loads.

    • 2

      Double-click the ASP.NET code file in Solution Explorer to open the source code for your GridView.

    • 3

      Create a string for the GridView column value. The following code shows you how to create a string variable, which is the data type used for the column's value:

      string selectedVal = string.Empty;

    • 4

      Assign the GridView's column value to the variable already created. The following code shows you how to get the value of a cell:

      selectedVal = gridView1.SelectedValue.ToString()

      Replace "gridView1" with the name of your own GridView control.

Related Searches:

References

Comments

Related Ads

Featured