Articles in this section
Category / Section

Column values are empty while binding it to SQL datasource.

1 min read

You need to specify the correct field names to the Grid Columns as per the selected table in the SQL DataSource. The Column names of the Grid should be the same as the ones in the DataBase, otherwise it displays the Grid with empty data.

The following code demonstrates how to bind SQL data to Grid.


<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
        <ej:Grid ID="Grid1" runat="server" AllowPaging="True" AllowSorting="True" DataSourceID="SqlDataSource1" MinWidth="0">
                <ej:Column Field="OrderID" HeaderText=" Order ID" IsPrimaryKey="True" TextAlign="Right" Width="75" />
                <ej:Column Field="EmployeeID" HeaderText="Employee ID" Width="80" />
                <ej:Column Field="Freight" HeaderText="Freight" TextAlign="Right" Format="{0:C}" Width="90" />
                <ej:Column Field="ShipCity" HeaderText="City" Width="75" />
                <ej:Column Field="ShipCountry" HeaderText="Country" Width="80" />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SQLConnectionString %>"
            SelectCommand="SELECT OrderID,EmployeeID,Freight,ShipCity,ShipCountry FROM [Orders]"></asp:SqlDataSource>

The following screenshot illustrates the output.

Figure 1: Grid SQL binding


Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment