Link to home
Start Free TrialLog in
Avatar of kiranboi
kiranboi

asked on

Programatically Adding items to a DataGridView ComboBox Cell

Hi all,

I have a ComboBox on my form that I use the following code to populate:
        For i As Integer = 0 To myDeliveryServicesDataTable.Rows.Count - 1
            myItem = myDeliveryServicesDataTable.Rows(i)("Name")
            cmboxDelService.Items.Add(myItem)
        Next
How can I do the same to a ComboBox cell in a DataGridView?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Ashish Patel
Ashish Patel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Pratima
<asp:TemplateColumn HeaderText="R2">
                                                            <ItemTemplate>
                                                                  <asp:DropDownList id="ddlGroup" runat="server" Width="100" CssClass="Dropdown"></asp:DropDownList>
                                                            </ItemTemplate>
                                                      </asp:TemplateColumn>


on ItemDataBound event of gridview

if ( e.Item.ItemType ==ListItemType.Item || e.Item.ItemType ==ListItemType.AlternatingItem )
                  {
                        Dim ddlGroup  as DropDownList = CType(e.Item.FindControl("ddlGroup"),DropDownList )
                        For i As Integer = 0 To myDeliveryServicesDataTable.Rows.Count - 1
            myItem = myDeliveryServicesDataTable.Rows(i)("Name")
            ddlGroup.Items.Add(myItem)
        Next


}