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

GridDropDownColumn Bind From Code Behind

1 Answer 312 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shafees
Top achievements
Rank 2
Shafees asked on 27 Oct 2010, 08:05 AM

How can i bind GridDropDownColumn with dataset from behind code


telerik:RadGrid ID="radgdBOQ" runat="server" AutoGenerateColumns="False" GridLines="None"
        OnNeedDataSource="radgdBOQ_NeedDataSource" OnInsertCommand="radgdBOQ_InsertCommand"
        ShowStatusBar="True" OnDeleteCommand="radgdBOQ_DeleteCommand" OnUpdateCommand="radgdBOQ_UpdateCommand"
        Skin="WebBlue">
        <MasterTableView DataKeyNames="bqmiBoqID" CommandItemDisplay="TopAndBottom">
            <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderButtonType="None" HeaderText="Edit">
                    <HeaderStyle HorizontalAlign="Center" Width="35px" />
                    <ItemStyle HorizontalAlign="Center" />
                </telerik:GridEditCommandColumn>
                <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ConfirmDialogType="RadWindow"
                    ConfirmText="Are You Sure To Delete ?" ConfirmTitle="Delete" HeaderButtonType="None"
                    HeaderText="Delete" Text="Delete" UniqueName="DeleteCommandColumn">
                    <HeaderStyle HorizontalAlign="Center" Width="50px" />
                    <ItemStyle HorizontalAlign="Center" />
                </telerik:GridButtonColumn>
                <telerik:GridNumericColumn DataField="bqmiItemCode" DataType="System.Int32" HeaderText="Item Code"
                    UniqueName="bqmiItemCode">
                    <HeaderStyle HorizontalAlign="Center" Width="75px" />
                    <ItemStyle HorizontalAlign="Left" />
                </telerik:GridNumericColumn>
                <telerik:GridBoundColumn DataField="bqmiItemDescription" HeaderText="Description"
                    UniqueName="bqmiItemDescription">
                    <HeaderStyle HorizontalAlign="Center" Width="150px" />
                    <ItemStyle HorizontalAlign="Left" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="bqmiUnit" HeaderText="Unit" UniqueName="bqmiUnit">
                    <HeaderStyle HorizontalAlign="Center" Width="50px" />
                    <ItemStyle HorizontalAlign="Left" />
                </telerik:GridBoundColumn>
                <telerik:GridNumericColumn DataField="bqmiPrice" DataType="System.Decimal" HeaderText="Price"
                    NumericType="Currency" UniqueName="bqmiPrice" DefaultInsertValue="0">
                    <HeaderStyle HorizontalAlign="Center" Width="100px" />
                    <ItemStyle HorizontalAlign="Right" />
                </telerik:GridNumericColumn>
                <telerik:GridNumericColumn DataField="bqmiQty" DataType="System.Decimal" HeaderText="Quantity"
                    UniqueName="bqmiQty" DefaultInsertValue="0">
                    <HeaderStyle HorizontalAlign="Center" Width="100px" />
                    <ItemStyle HorizontalAlign="Right" />
                </telerik:GridNumericColumn>
                <telerik:GridCalculatedColumn DataFields="bqmiPrice,bqmiQty" DataType="System.Decimal"
                    Expression="{0}*{1}" HeaderText="Amount" UniqueName="bqmiAmount">
                </telerik:GridCalculatedColumn>
                <telerik:GridDropDownColumn HeaderText="Drop" UniqueName="drop" DataField="drop"
                    DefaultInsertValue="0">
                </telerik:GridDropDownColumn>
            </Columns>
            <EditFormSettings>
                <EditColumn UniqueName="EditCommandColumn1">
                </EditColumn>
            </EditFormSettings>
        </MasterTableView>
        <ClientSettings>
            <Scrolling AllowScroll="True" UseStaticHeaders="True" />
        </ClientSettings>
    </telerik:RadGrid>


 

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 27 Oct 2010, 08:31 AM
Hello Shafees,

The following code shows how to display value in GridDropDownColumn in normal mode.

C#:
protected void radgdBOQ_ItemDataBound(object sender, GridItemEventArgs e)
  {
      if (e.Item is GridDataItem)
      {
          GridDataItem item = (GridDataItem)e.Item;
          DataRowView row = (DataRowView)e.Item.DataItem;
          item["drop"].Text = row["drop"].ToString();
      }
  }

You can refer the following forum post which explains how to populate GridDropDowmColumn in edit mode from code behind.
GridDropDownColumn comboBox doesn't display items

For more information on this please refer the following documentation.
Customize/Configure GridDropDownColumn

Thanks,
Princy.
Tags
Grid
Asked by
Shafees
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Share this question
or