BoundColumn Class
TOC
Collapse the table of content
Expand the table of content

BoundColumn Class

 

A column type for the DataGrid control that is bound to a field in a data source.

Namespace:   System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

System.Object
  System.Web.UI.WebControls.DataGridColumn
    System.Web.UI.WebControls.BoundColumn

public class BoundColumn : DataGridColumn

NameDescription
System_CAPS_pubmethodBoundColumn()

Initializes a new instance of the BoundColumn class.

NameDescription
System_CAPS_pubpropertyDataField

Gets or sets the field name from the data source to bind to the BoundColumn.

System_CAPS_pubpropertyDataFormatString

Gets or sets the string that specifies the display format for items in the column.

System_CAPS_protpropertyDesignMode

Gets a value that indicates whether the column is in design mode.(Inherited from DataGridColumn.)

System_CAPS_pubpropertyFooterStyle

Gets the style properties for the footer section of the column.(Inherited from DataGridColumn.)

System_CAPS_pubpropertyFooterText

Gets or sets the text displayed in the footer section of the column.(Inherited from DataGridColumn.)

System_CAPS_pubpropertyHeaderImageUrl

Gets or sets the location of an image to display in the header section of the column.(Inherited from DataGridColumn.)

System_CAPS_pubpropertyHeaderStyle

Gets the style properties for the header section of the column.(Inherited from DataGridColumn.)

System_CAPS_pubpropertyHeaderText

Gets or sets the text displayed in the header section of the column.(Inherited from DataGridColumn.)

System_CAPS_protpropertyIsTrackingViewState

Gets a value that determines whether the DataGridColumn object is marked to save its state.(Inherited from DataGridColumn.)

System_CAPS_pubpropertyItemStyle

Gets the style properties for the item cells of the column.(Inherited from DataGridColumn.)

System_CAPS_protpropertyOwner

Gets the DataGrid control that the column is a member of.(Inherited from DataGridColumn.)

System_CAPS_pubpropertyReadOnly

Gets or sets a value that indicates whether the items in the BoundColumn can be edited.

System_CAPS_pubpropertySortExpression

Gets or sets the name of the field or expression to pass to the OnSortCommand method when a column is selected for sorting.(Inherited from DataGridColumn.)

System_CAPS_protpropertyViewState

Gets the System.Web.UI.StateBag object that allows a column derived from the DataGridColumn class to store its properties.(Inherited from DataGridColumn.)

System_CAPS_pubpropertyVisible

Gets or sets a value that indicates whether the column is visible in the DataGrid control.(Inherited from DataGridColumn.)

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_protmethodFormatDataValue(Object)

Converts the specified value to the format indicated by the DataFormatString property.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodInitialize()

Resets the BoundColumn to its initial state.(Overrides DataGridColumn.Initialize().)

System_CAPS_pubmethodInitializeCell(TableCell, Int32, ListItemType)

Resets the specified cell in the BoundColumn to its initial state.(Overrides DataGridColumn.InitializeCell(TableCell, Int32, ListItemType).)

System_CAPS_protmethodLoadViewState(Object)

Loads the state of the DataGridColumn object.(Inherited from DataGridColumn.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodOnColumnChanged()

Calls the DataGridDesigner.OnColumnsChanged method.(Inherited from DataGridColumn.)

System_CAPS_protmethodSaveViewState()

Saves the current state of the DataGridColumn object.(Inherited from DataGridColumn.)

System_CAPS_pubmethodToString()

Returns the string representation of the column.(Inherited from DataGridColumn.)

System_CAPS_protmethodTrackViewState()

Causes tracking of view-state changes to the server control so they can be stored in the server control's System.Web.UI.StateBag object.(Inherited from DataGridColumn.)

NameDescription
System_CAPS_pubfieldSystem_CAPS_staticthisExpr

Represents the string "!". This field is read-only.

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIStateManager.LoadViewState(Object)

This API supports the product infrastructure and is not intended to be used directly from your code. Loads previously saved state.(Inherited from DataGridColumn.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIStateManager.SaveViewState()

This API supports the product infrastructure and is not intended to be used directly from your code. Returns an object containing state changes.(Inherited from DataGridColumn.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIStateManager.TrackViewState()

This API supports the product infrastructure and is not intended to be used directly from your code. Starts tracking state changes.(Inherited from DataGridColumn.)

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIStateManager.IsTrackingViewState

This API supports the product infrastructure and is not intended to be used directly from your code. Gets a value that indicates whether the column is tracking view state changes.(Inherited from DataGridColumn.)

Use the BoundColumn column type in a DataGrid control to display the contents of a field in the data source. The values are listed in a single column. The field is linked to the BoundColumn, so any updates in the data source will reflect in the corresponding cells of the DataGrid control.

System_CAPS_noteNote

This column type is the default for the DataGrid control.

To control appearance of this column, use the style properties of the DataGrid control.

System_CAPS_cautionCaution

Text is not HTML encoded before it is displayed in the BoundColumn. This makes it possible to embed script within HTML tags in the text. If the values for this column come from user input, be sure to validate the values to reduce security vulnerabilities.

The following example demonstrates how to use a BoundColumn column type in the DataGrid control to display the fields in a data source.

<%@ Page Language="C#" AutoEventWireup="True" %>
<%@ Import Namespace="System.Data" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
   <script language="C#" runat="server">

      ICollection CreateDataSource() 
      {
         DataTable dt = new DataTable();
         DataRow dr;

         dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
         dt.Columns.Add(new DataColumn("StringValue", typeof(string)));
         dt.Columns.Add(new DataColumn("CurrencyValue", typeof(double)));

         for (int i = 0; i < 9; i++) 
         {
            dr = dt.NewRow();

            dr[0] = i;
            dr[1] = "Item " + i.ToString();
            dr[2] = 1.23 * (i + 1);

            dt.Rows.Add(dr);
         }

         DataView dv = new DataView(dt);
         return dv;
      }

      void Page_Load(Object sender, EventArgs e) 
      {

         if (!IsPostBack) 
         {
            // Load this data only once.
            ItemsGrid.DataSource= CreateDataSource();
            ItemsGrid.DataBind();
         }
      }

   </script>

<head runat="server">
    <title>BoundColumn Example</title>
</head>
<body>

   <form id="form1" runat="server">

      <h3>BoundColumn Example</h3>

      <b>Product List</b>

      <asp:DataGrid id="ItemsGrid"
           BorderColor="black"
           BorderWidth="1"
           CellPadding="3"
           AutoGenerateColumns="false"
           runat="server">

         <HeaderStyle BackColor="#00aaaa">
         </HeaderStyle>

         <Columns>

            <asp:BoundColumn
                 HeaderText="Number" 
                 DataField="IntegerValue">
            </asp:BoundColumn>

            <asp:BoundColumn
                 HeaderText="Description" 
                 DataField="StringValue">
            </asp:BoundColumn>

            <asp:BoundColumn
                 HeaderText="Price" 
                 DataField="CurrencyValue" 
                 DataFormatString="{0:c}">
            </asp:BoundColumn>

         </Columns>

      </asp:DataGrid>

   </form>

</body>
</html>

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft