Back to Devexpress

ASPxDataWebControlBase.DataSource Property

aspnet-devexpress-dot-web-dot-aspxdatawebcontrolbase.md

latest7.0 KB
Original Source

ASPxDataWebControlBase.DataSource Property

Specifies the object from which the data-bound control retrieves its data items.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
[DefaultValue(null)]
public virtual object DataSource { get; set; }
vb
<DefaultValue(Nothing)>
Public Overridable Property DataSource As Object

Property Value

TypeDefaultDescription
Objectnull

The data source object from which the data-bound control retrieves its data.

|

Remarks

Use the DataBind() method to bind a control to the specified data source.

You cannot specify this property in a theme.

aspx
<dx:ASPxTitleIndex ID="ASPxTitleIndex1" runat="server">
    <!-- ... -->
</dx:ASPxTitleIndex>
csharp
protected void Page_Load(object sender, EventArgs e) {
    string[] names = File.ReadAllLines(Server.MapPath("~/App_Data/customers.txt"), Encoding.Unicode);
    ASPxTitleIndex1.DataSource = names;
    ASPxTitleIndex1.DataBind();
}
vb
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    Dim names As String() = File.ReadAllLines(Server.MapPath("~/App_Data/customers.txt"), Encoding.Unicode)
    ASPxTitleIndex1.DataSource = names
    ASPxTitleIndex1.DataBind()
End Sub

Note

For ASPxRichEdit only:

The DataSource property specifies a data source for the Mail Merge feature. The property accepts an object that implements the IList interface. If a bound data source contains multiple data tables, use the DataMember property to specify a data member.

See Also: How to: Change the Mail Merge data sources at runtime

The following code snippets (auto-collected from DevExpress Examples) contain references to the DataSource 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-master-detail-grid-at-runtime/CS/MasterDetailGrids/Default.aspx.cs#L35

csharp
masterGrid.KeyFieldName = "CategoryID";
masterGrid.DataSource = GetMasterDataSource();

asp-net-web-forms-grid-entitydatasource-and-common-scenarios/CS/GridEntityFramework/ServerModeEF.aspx.cs#L28

csharp
protected void grid_DataBinding(object sender, EventArgs e) {
    (sender as ASPxGridView).DataSource = GetEntityServerModeSource();
}

asp-net-web-forms-implement-pdf-viewer/CS/PdfViewer.ascx.cs#L95

csharp
}
dvDocument.DataSource = data;
dvDocument.DataBind();

asp-net-web-forms-grid-bind-master-and-detail-grids-to-list-data-sources/CS/Default.aspx.cs#L41

csharp
protected void Page_Init(object sender, EventArgs e) {
    masterGrid.DataSource = ParentData;
    masterGrid.DataBind();

aspxgridview-edit-in-memory-dataset/CS/WebApp/Default.aspx.cs#L34

csharp
ds = (DataSet)Session["DataSet"];
MasterGridView.DataSource = ds.Tables[0];
MasterGridView.DataBind();

asp-net-web-forms-grid-create-master-detail-grid-at-runtime/VB/MasterDetailGrids/Default.aspx.vb#L37

vb
masterGrid.KeyFieldName = "CategoryID"
masterGrid.DataSource = GetMasterDataSource()

asp-net-web-forms-grid-entitydatasource-and-common-scenarios/VB/GridEntityFramework/ServerModeEF.aspx.vb#L29

vb
Protected Sub grid_DataBinding(ByVal sender As Object, ByVal e As EventArgs)
    TryCast(sender, ASPxGridView).DataSource = GetEntityServerModeSource()
End Sub

asp-net-web-forms-implement-pdf-viewer/VB/PdfViewer.ascx.vb#L101

vb
Me.dvDocument.DataSource = data
Me.dvDocument.DataBind()

asp-net-web-forms-grid-bind-master-and-detail-grids-to-list-data-sources/VB/Default.aspx.vb#L39

vb
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
    masterGrid.DataSource = ParentData
    masterGrid.DataBind()

aspxgridview-edit-in-memory-dataset/VB/WebApp/Default.aspx.vb#L40

vb
MasterGridView.DataSource = ds.Tables(0)
MasterGridView.DataBind()

See Also

DataSourceID

ASPxDataWebControlBase Class

ASPxDataWebControlBase Members

DevExpress.Web Namespace