This is a migrated thread and some comments may be shown as answers.

GridDropDownColumn and SQL SELECT

1 Answer 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
vadim
Top achievements
Rank 1
vadim asked on 13 Apr 2011, 07:49 PM
Hello.

I need to add a drop-down column to RadGrid  at Page_Load.
I have SQLDataSource in ASP.

C# code:
GridDropDownColumn ddColumn = new GridDropDownColumn();
RadGridTable.MasterTableView.Columns.Add(ddColumn);
ddColumn.DataSourceID = "LookupDS";
ddColumn.DataField = "table_name";
ddColumn.ListValueField = "id";
ddColumn.ListTextField = "name";

Everything works fine with SQL statement:
SELECT s.name AS id, s.name AS name
FROM sys.sysobjects s LEFT JOIN org_menu m ON (s.name=m.table_name)
WHERE (s.xtype='U') ORDER BY s.id

Then I slightly modify SQL to skip existing tables:
SELECT s.name AS id, s.name AS name
FROM sys.sysobjects s LEFT JOIN org_menu m ON (s.name=m.table_name)
WHERE ( (s.xtype='U') AND ( m.table_name IS NULL ) ) ORDER BY s.id

Now in that specific grid column all cells are empty.
However if I open row in editor the value shows up (in editor).

I checked SQL statements in management studio - both work fine.
The only difference is that the first returns more rows.

Any suggestions?

1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 19 Apr 2011, 07:52 AM
Hi Vadim,

The values are empty into the grid view mode because you select all fields which are null:
WHERE ( (s.xtype='U') AND ( m.table_name IS NULL ) ) ORDER BY s.id

Additionally you should set the ListValueField property to the name of the field in the lookup table that supplies the value for the field specified by the DataField property. More information you could find on the following online documentation articles:
http://www.telerik.com/help/aspnet-ajax/grid-customize-configure-griddropdowncolumn.html
http://www.telerik.com/help/aspnet-ajax/grid-column-types.html

Best wishes,
Radoslav
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
vadim
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or