obout combobox in datagrid

1.3k Views Asked by At

I have an asp:gridview that i'm trying to replace the asp:dropdownlist with a obout:combobox. I'm using a combobox on the page outside of the grid and it works as expected. In the gridview the code looks like this

 <asp:GridView ID="dgKSA" runat="server" AutoGenerateColumns="False" GridLines="none"
    Width="980px" Style="border: 1px solid #404040" CellPadding="5" AlternatingRowStyle-BackColor="#F0F3F4"
    ShowHeader="false">
    <Columns>
        <asp:TemplateField ItemStyle-VerticalAlign="top">
            <ItemTemplate>
                <obout:ComboBox ID="ddlImportanceInDg" runat="server" Visible="true" Enabled="true" >
                    <obout:ComboBoxItem ID="ComboBoxItem1" runat="server" Value="5" Text="Extremely Important" />
                    <obout:ComboBoxItem ID="ComboBoxItem2" runat="server" Value="4" Text="Important" />
                    <obout:ComboBoxItem ID="ComboBoxItem3" runat="server" Value="3" Text="Moderately Important" />
                    <obout:ComboBoxItem ID="ComboBoxItem4" runat="server" Value="2" Text="Unimportant" />
                    <obout:ComboBoxItem ID="ComboBoxItem5" runat="server" Value="1" Text="Extremely Unimportant" />
                    <obout:ComboBoxItem ID="ComboBoxItem6" runat="server" Value="99" Text="Not Applicable"
                        Selected="true" />
                </obout:ComboBox>
                <%--<asp:DropDownList runat="server" ID="ddlImportanceInDg">
                    <asp:ListItem Value="5">Extremely Important</asp:ListItem>
                    <asp:ListItem Value="4">Important</asp:ListItem>
                    <asp:ListItem Value="3">Moderately Important</asp:ListItem>
                    <asp:ListItem Value="2">Unimportant</asp:ListItem>
                    <asp:ListItem Value="1">Extremely Unimportant</asp:ListItem>
                    <asp:ListItem Value="99" Selected="true">Not Applicable</asp:ListItem>
                </asp:DropDownList>--%>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

that's it... when the page draws, the combobox shows up but only the last combox has any items in it.

was hoping someone had an idea. Thanks shannon

1

There are 1 best solutions below

0
On

I realize you asked this 7 months ago, but I had the same issue and found a solution, so I thought I'd share it.

Basically, you have to assign the ComboBox a unique ID when the row is created.

Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim ComboBox1 As Obout.ComboBox.ComboBox = CType(e.Row.FindControl("ComboBox1"), Obout.ComboBox.ComboBox)

            ComboBox1.ID = "ComboBox1_" & e.Row.RowIndex
        End If
End Sub