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

Drop Down List DataSource = Datatable

1 Answer 231 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bastian
Top achievements
Rank 1
Bastian asked on 21 Jan 2013, 10:20 AM
Hi
I have a grid with follwing columns.. the Calumn TRANSACTION_CURRENCY_CD should be a DropDown list

.....
      <Columns>   
      <telerik:GridBoundColumn ReadOnly="true" DataField="ACCOUNT_ID" UniqueName="ACCOUNT_ID"
        HeaderText="Account ID">
        </telerik:GridBoundColumn>
     <telerik:GridDropDownColumn UniqueName="TRANSACTION_CURRENCY_CD" ListTextField="TRANSACTION_CURRENCY_CD"
  ListValueField="TRANSACTION_CURRENCY_CD" HeaderText="DropDown Column"
  DataField="TRANSACTION_CURRENCY_CD" DropDownControlType="RadComboBox" AllowSorting="true">
</telerik:GridDropDownColumn>
       <telerik:GridBoundColumn DataField="TRANSACTION_AMT" UniqueName="TRANSACTION_AMT" HeaderText="TRANSACTION_AMT">
      </telerik:GridBoundColumn>
             <telerik:GridBoundColumn DataField="LOCAL_CURRENCY_CD" UniqueName="LOCAL_CURRENCY_CD" HeaderText="LOCAL_CURRENCY_CD">
      </telerik:GridBoundColumn>
             <telerik:GridBoundColumn DataField="LOCAL_AMT" UniqueName="LOCAL_AMT" HeaderText="LOCAL_AMT">
      </telerik:GridBoundColumn>
             <telerik:GridBoundColumn DataField="SUB1" UniqueName="SUB1" HeaderText="SUB1">
      </telerik:GridBoundColumn>
                   <telerik:GridBoundColumn DataField="SUB2" UniqueName="SUB2" HeaderText="SUB2">
      </telerik:GridBoundColumn>
    </Columns>
 
.....

public DataTable  CustomersTable
{
 
    get
    {
        DataTable  res = (DataTable)this.Session["CustomersTable"];
        if (res == null)
        {
            res = (DataTable)Table0021.Lade("1").Tables[0];
            this.Session["CustomersTable"] = res;
        }
 
        return res;
    }
}

    protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        RadGrid1.DataSource = this.CustomersTable;
    }

TRANSACTION_CURRENCY_CD is the column name in the Datatable

2 questions /problems:

- the CalumnTRANSACTION_CURRENCY_CD is always Empty (in the edit mode, too)
- I get a List<String> with the Elemts for the DropDownList. How can I bind this to the dropdownlist


Thank you very much!

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Jan 2013, 10:33 AM
Hi,

Try accessing the dropdowncolumn as shown below.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            GridEditableItem item = (GridEditableItem)e.Item;
            RadComboBox combo = (RadComboBox)item["TRANSACTION_CURRENCY_CD"].Controls[0];
            //populate the combo here
        }
}

Thanks,
Shinu
Tags
Grid
Asked by
Bastian
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or