aspnet-devexpress-dot-web-dot-gridviewdatacolumn-0607aaba.md
Gets or sets the name of the database field assigned to the current column.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
[DefaultValue("")]
public virtual string FieldName { get; set; }
<DefaultValue("")>
Public Overridable Property FieldName As String
| Type | Default | Description |
|---|---|---|
| String | String.Empty |
A String value that specifies the name of a data field.
|
To specify the text which is displayed within the column’s header, use the Caption property.
It is not allowed to set the FieldName property of several columns to the same data source’s field. The FieldName property should be set to a unique value.
For unbound columns, the FieldName should not refer to any field in ASPxGridView’s data source. Refer to the Unbound Columns topic for more information.
The example below demonstrates how to specify the display text for a cell:
<dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" KeyFieldName="ID" Width="100%"
OnCustomColumnDisplayText="grid_CustomColumnDisplayText">
<Columns>
<dx:GridViewDataTextColumn FieldName="From" Width="200px" />
<dx:GridViewDataTextColumn FieldName="Subject" />
<dx:GridViewDataDateColumn FieldName="Sent" Width="100px" />
<dx:GridViewDataCheckColumn Caption="Attachment?" FieldName="HasAttachment" Width="100px" />
<dx:GridViewDataTextColumn FieldName="Size" Width="80px" />
</Columns>
</dx:ASPxGridView>
protected void grid_CustomColumnDisplayText(object sender, ASPxGridViewColumnDisplayTextEventArgs e) {
if(e.Column.FieldName == "Size")
e.DisplayText = Utils.FormatSize(e.Value);
}
Run Demo: ASPxGridView - Large Database
The following code snippets (auto-collected from DevExpress Examples) contain references to the FieldName property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
asp-net-web-forms-grid-create-report-based-on-grid-layout/CS/WebApplication1/ReportHelper.cs#L70
label.SizeF = ((XRTableCell)detailsInfo[col]).SizeF;
label.DataBindings.Add("Text", null, ((GridViewDataColumn)col).FieldName);
label.Summary = new XRSummary() { Running = SummaryRunning.Group };
GridViewDataColumn colProductID = new GridViewDataColumn();
colProductID.FieldName = "ProductID";
colProductID.EditFormSettings.Visible = DevExpress.Utils.DefaultBoolean.False;
asp-net-web-forms-grid-set-edit-form-values/CS/Solution/ClientSide.aspx.cs#L9
protected void grdProducts_CustomUnboundColumnData(object sender, DevExpress.Web.ASPxGridViewColumnDataEventArgs e) {
if (e.Column.FieldName == "Total") {
decimal price = (decimal)e.GetListSourceFieldValue("UnitPrice");
if (e.Column.FieldName == "DataValue") {
switch (dataType) {
asp-net-web-forms-grid-create-hyperlink-column-at-runtime/CS/Default.aspx.cs#L37
GridViewDataTextColumn colID = new GridViewDataTextColumn();
colID.FieldName = "ID";
ASPxGridView1.Columns.Add(colID);
asp-net-web-forms-grid-create-report-based-on-grid-layout/VB/WebApplication1/ReportHelper.vb#L72
label.SizeF = DirectCast(detailsInfo(col), XRTableCell).SizeF
label.DataBindings.Add("Text", Nothing, CType(col, GridViewDataColumn).FieldName)
label.Summary = New XRSummary() With {.Running = SummaryRunning.Group}
Dim colProductID As New GridViewDataColumn()
colProductID.FieldName = "ProductID"
colProductID.EditFormSettings.Visible = DevExpress.Utils.DefaultBoolean.False
asp-net-web-forms-grid-set-edit-form-values/VB/Solution/ClientSide.aspx.vb#L12
Protected Sub grdProducts_CustomUnboundColumnData(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxGridViewColumnDataEventArgs)
If Equals(e.Column.FieldName, "Total") Then
Dim price As Decimal = CDec(e.GetListSourceFieldValue("UnitPrice"))
If e.Column.FieldName = "DataValue" Then
Select Case dataType
asp-net-web-forms-grid-create-hyperlink-column-at-runtime/VB/Default.aspx.vb#L34
Dim colID As GridViewDataTextColumn = New GridViewDataTextColumn()
colID.FieldName = "ID"
ASPxGridView1.Columns.Add(colID)
See Also