RadGrid for ASP.NET

RadGrid Send comments on this topic.
DataSourceID Property
See Also  Example
Telerik.WebControls Namespace > RadGrid Class : DataSourceID Property


Gets or sets the ID of the control from which the Telerik RadGrid control retrieves its list of data items.

  

 

Namespace: Telerik.WebControls
Assembly: RadGrid (in RadGrid.dll)

Syntax

Visual Basic (Declaration) 
Overrides Public Property DataSourceID As String
Visual Basic (Usage)Copy Code
Dim instance As RadGrid
Dim value As String
 
instance.DataSourceID = value
 
value = instance.DataSourceID
C# 
public override string DataSourceID {get; set;}

Return Value

The ID of a control that represents the data source from which the Telerik RadGrid control retrieves its data. The default is String.Empty.

Example

The following code example demonstrates how the DataSourceID property of a Telerik RadGrid control is used. The Telerik RadGrid control is associated to the SqlDataSource control by setting its DataSourceID property to "SqlDataSource1", the ID of the SqlDataSource control. When the DataSourceID property is set (instead of the DataSource property), the Telerik RadGrid control automatically binds to the data source control at run time.
Visual BasicCopy Code
<%@ Page Language="VB" <see cref="> <"/>@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>

<!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" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <rad:RadGrid
            DataSourceID="SqlDataSource1"
            ID="RadGrid1"
            runat="server">
        </rad:RadGrid>
        <!-- This example uses Microsoft SQL Server and connects -->
        <!-- to the Northwind sample database. Use an ASP.NET -->
        <!-- expression to retrieve the connection string value -->
        <!-- from the Web.config file. -->
        <asp:SqlDataSource
            ID="SqlDataSource1"
            runat="server"
            ConnectionString="<<see cref="NorthwindConnectionString">$ ConnectionStrings</see>>"
            SelectCommand="SELECT [CustomerID], [ContactName], [CompanyName] FROM [Customers]">
        </asp:SqlDataSource>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></div>
    
</body>
</html>

Remarks

If the Telerik RadGrid control has already been initialized when you set the DataSourceID property.

This property cannot be set by themes or style sheet themes.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also