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

GridDropDownColumn not showing

1 Answer 128 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lukus
Top achievements
Rank 1
Lukus asked on 10 Jun 2011, 09:49 PM
The GridDropDownColumn is working perfectly other than displaying the values from the database.  The Dropdownlist is populated in edit mode and it inserts to the database just fine, but when i just try to display that info from the database in the column it doesn't show anything.

Grid:
<telerik:RadGrid ID="rg_Collateral" runat="server" Width="450px" AllowSorting="true"
                                                    GridLines="Both" AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="true"
                                                    PageSize="5" AllowPaging="true" AutoGenerateColumns="false" Skin="Simple" DataSourceID="collateral_Entity"
                                                    OnItemDataBound="rg_Collateral_ItemDataBound" Font-Names="Calibri">
                                                    <MasterTableView Width="100%" CommandItemDisplay="Top">
                                                        <Columns>
                                                            <telerik:GridBoundColumn DataField="USERID" HeaderText="User ID" UniqueName="userid"
                                                                ReadOnly="true" Display="false" />
                                                            <telerik:GridBoundColumn DataField="CONUM" HeaderText="CoNum" UniqueName="conum"
                                                                ReadOnly="true" Display="false" />
                                                            <telerik:GridBoundColumn DataField="DATEENTERED" HeaderText="Date Ent." UniqueName="dateEntered"
                                                                ReadOnly="true" DataFormatString="{0:MM/dd/yyyy}" />
                                                            <telerik:GridDateTimeColumn DataField="RELEASED" HeaderText="Date Rel." UniqueName="dateReleased"
                                                                DataFormatString="{0:MM/dd/yyyy}" />
                                                            <telerik:GridDropDownColumn DataField="COLLATERALTYPE" HeaderText="Type" UniqueName="type"
                                                                DropDownControlType="DropDownList" />
                                                            <telerik:GridNumericColumn DataField="COLLATERALAMT" HeaderText="Collateralamt" UniqueName="collateralamt" />
                                                            <telerik:GridDateTimeColumn DataField="EXPDATE" HeaderText="Date Exp." UniqueName="dateExpired"
                                                                DataFormatString="{0:MM/dd/yyyy}" />
                                                            <telerik:GridBoundColumn DataField="AUTORENEW" HeaderText="Auto Ren." UniqueName="autoRenew"
                                                                Display="false" />
                                                            <telerik:GridBoundColumn DataField="BONDNUM" HeaderText="bond #" UniqueName="bondNumber"
                                                                ReadOnly="true" />
                                                            <telerik:GridBoundColumn DataField="DESCRIPTION" HeaderText="Desc." UniqueName="description" />
                                                        </Columns>
                                                    </MasterTableView>
                                                    <PagerStyle Mode="NextPrevNumericAndAdvanced" />
                                                </telerik:RadGrid>

ItemDataBound
protected void rg_Collateral_ItemDataBound(object sender, GridItemEventArgs e)
        {
            hdBondnum.Value = txt_BondNumber.Text;
            hdConum.Value = txt_AccountNumber.Text;
            hduserid.Value = Membership.GetUser().ToString();
            if ((e.Item is GridEditFormInsertItem) && (e.Item.OwnerTableView.IsItemInserted))
            {
                GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
                TextBox txtbx = (TextBox)insertItem["userid"].Controls[0];
                TextBox txtbx2 = (TextBox)insertItem["conum"].Controls[0];
                TextBox txtbx3 = (TextBox)insertItem["dateEntered"].Controls[0];
                TextBox txtbx4 = (TextBox)insertItem["bondNumber"].Controls[0];
 
                GridEditableItem editItem = e.Item as GridEditableItem; 
                GridEditManager editMgr = editItem.EditManager;
                GridDropDownListColumnEditor colEditor = editMgr.GetColumnEditor("type") as GridDropDownListColumnEditor;
                string s = colEditor.SelectedValue;
                colEditor.DataSource = UtilityBond.getCollateralType();
                colEditor.DataBind(); 
 
                txtbx.Text = hduserid.Value;
                txtbx2.Text = hdConum.Value;
                txtbx3.Text = String.Format("{0:M/d/yyyy}", DateTime.Today.Date);
                txtbx4.Text = hdBondnum.Value;
            }
        }

The CollateralType is the only column that is not displaying any data in the grid.

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 16 Jun 2011, 06:36 AM
Hi Lukus,

Inspecting your code snippets I could not see where you are passing data to the drop-down column when the grid is in DisplayMode. Your code in the ItemDataBound event will populated the drop-down only in the insert form on account of the condition if(.... && e.Item.OwnerTableView.IsItemInserted). Please, provide more details and paste your complete aspx and code-behind using the CODE-FORMATTER tool of the ticket editor. 

Regards,
Tsvetoslav
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
Lukus
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or