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

Using DropDownColumn in RadGrid

3 Answers 163 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark Ferkaluk
Top achievements
Rank 1
Mark Ferkaluk asked on 18 Aug 2011, 10:00 AM

Hi Folks,

first of all, I'm new to Telerik controls. I'm using a RadGrid to display some data, which contains a DropDown column. The grid is bound to a data table on the page load event. Source of this is a SQL server. Here some Code of my binding:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
 Dim table_competitor_work As DataTable = getSQLData("SELECT competitor, value, units FROM competitor_work")
 RadGrid1.DataSource = table_competitor_work
 RadGrid1.DataBind()
End Sub
 
Protected Function getSQLData(ByVal query As String) As DataTable
   Dim connString As String = "Data Source=home-sps2010\POWERPIVOT;Initial Catalog=marketsurvey;Integrated Security=SSPI;"
   Dim conn As New SqlConnection(connString)
   Dim cmd As SqlCommand = New SqlCommand(query, conn)
   conn.Open()
 
   Dim dr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
 
   Dim dt As New DataTable
   dt.Load(dr)
   conn.Close()
 
   Return dt
End Function


And here is my markup code:

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"
                    AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" CellSpacing="0"
                    GridLines="Horizontal" Skin="Telerik" AllowAutomaticDeletes="True"
                    AllowAutomaticInserts="True" AllowAutomaticUpdates="True">
                    <MasterTableView CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add new customer">
                        <CommandItemSettings ExportToPdfText="Export to PDF" />
                        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                            <HeaderStyle Width="20px" />
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                            <HeaderStyle Width="20px" />
                        </ExpandCollapseColumn>
                        <Columns>
                            <telerik:GridDropDownColumn EmptyListItemText="Empty"
                                EmptyListItemValue="Empty" FilterControlAltText="Filter Customer column"
                                HeaderText="Competitor" UniqueName="Competitor" DataField="competitor">
                            </telerik:GridDropDownColumn>
                            <telerik:GridNumericColumn DecimalDigits="2"
                                FilterControlAltText="Filter Value column" HeaderText="Value 2010"
                                UniqueName="Value" DataField="value">
                            </telerik:GridNumericColumn>
                            <telerik:GridNumericColumn DecimalDigits="0"
                                FilterControlAltText="Filter Units column" HeaderText="Units 2010"
                                UniqueName="Units" DataField="units">
                            </telerik:GridNumericColumn>
                        </Columns>
                        <EditFormSettings>
                            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                            </EditColumn>
                        </EditFormSettings>
                    </MasterTableView>
                    <FilterMenu EnableImageSprites="False">
                    </FilterMenu>
                    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
                    </HeaderContextMenu>
                </telerik:RadGrid>


The strange thing is, the binding an everything works not on the dropdown column. Nothing is displayed and I don't now why. I wanted to bind the dropdown column to a sql datasource and in the insert and edit forms I wanted to diplay other data for the dropdown list. I thought I can do it that way:

DataField="SQLserverField" (bound in code behind at runtime)
DataSourceID="SQLDataSource" (same database, but other table)
ListTextField="SQLDataSourceField"
ListValueField="SQLDataSourceField"

But that isn't working so well. Still there are no value displayed in the grid. But On insert and edit the right values are there.

Do you have an idea?

Thanks and regards,
Mark

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 18 Aug 2011, 10:18 AM
Hello Mark,

When in browser mode, GridDropDownColumn looks and behaves like a standard GridBoundColumn. It is rendered only in edit mode. Check the following help documentation which explains more about this.
Column Types.

Thanks,
Princy.
0
Mark Ferkaluk
Top achievements
Rank 1
answered on 18 Aug 2011, 10:23 AM
Hello Princy,

thanks for replying. But I did exactly what is documented there. The only thing is, I use the grid in a SharePoint Visual WebPart, but that shouldn't make a difference.

Still in browser mode no values are displayed. When I use a bound column instead of a dropdown column, it works.

Regards,Mark
0
Mark Ferkaluk
Top achievements
Rank 1
answered on 18 Aug 2011, 10:33 AM
Args, I found my problem. It is also described in the documentation. ListValueField and DataField have to be the same values in order to work
Tags
Grid
Asked by
Mark Ferkaluk
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Mark Ferkaluk
Top achievements
Rank 1
Share this question
or