Avatar of yuvaratna
yuvaratna

asked on 

Dynamic Grid view

I have a grid view with 5 columns...The rows should be added dynamically.....the user needs to submit his Favourite Books. information..1 record per each row..as the user can have more than one favourite book ...he must be able to fill in the second row if he wants .so when the user is done filling the first row,the second row should be populated..I wanted each column to be a drop down from which he can select a value.....
How can i use a combo box or a dropdown from the gridview.

I tried this code for a dynamic grid view, But it throws few errors....Here is the code.

Its not recognsing "Bound field" and when i tried changing it to "Bound specified", its not allowing  the header text and data field properties...

any other ways to solve this???
Imports System.Data
 
Public Class dynamicgrid
 
    Private Sub dynamicgrid_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        loaddynamicgrid()
    End Sub
    Private Sub loaddynamicgrid()
        Dim dt As New DataTable
        Dim dcol As New DataColumn(ID, GetType(Integer))
        dcol.AutoIncrement = True
        dt.Columns.Add(dcol)
 
        dcol = New DataColumn(Name, GetType(String))
        dt.Columns.Add(dcol)
        For nindex As Integer = 0 To 9
            Dim drow As DataRow = dt.NewRow
            drow(Name) = "row-" & Convert.ToString((nindex + 1))
            dt.Rows.Add(drow)
        Next
        For Each col As DataColumn In dt.Columns
            Dim bfield As New Boundfied()
            bfield.DataField = col.ColumnName
            bfield.HeaderText = col.ColumnName
            Grddynamic.Columns.Add(bfield)
 
        Next
    End Sub
End Class

Open in new window

.NET ProgrammingVisual Basic.NET

Avatar of undefined
Last Comment
Bob Learned

8/22/2022 - Mon