Hi,
I am Struggling to attach or add new row in gridview after binding some existing bind data.
For Example,
I have 10 row in database.
When i am loading the page i should fetch all the 10 rows data. (Botton i will have "Add New Row Button")
In that, i want add 11th row when i click "Add New Row" button dynamically.
First columns contains Student Name ==> DropDown
Second Columns contains Stundent Number ==> TextBox.
So, when i click "Add new Row" button, My 11th Row should be Dropdown | Textbox to enter someting.
How to do this and attach the binding data...?
What I have tried:
If ds.Tables(1).Rows.Count > 0 Then
Dim dts As New DataSet
Dim dt As New DataTable()
Dim dr As DataRow
dt.Columns.Add(New DataColumn("StudentName"))
dt.Columns.Add(New DataColumn("StudentNumber"))
dr = dt.NewRow()
dr("DocType") = ""
dr("DocNumber") = ""
dt.Rows.Add(dr)
For Each gvr As GridViewRow In grdDocList.Rows
dr = dt.NewRow()
dr("ColumnName1") = DirectCast(gvr.Cells(0).FindControl("Label"), Label).Text
dr("ColumnName2") = DirectCast(gvr.Cells(1).FindControl("Label"), Label).Text
dt.Rows.Add(dr)
Next
dts.Tables.Add(dt)
dts = ds.Copy
Me.grdList.DataSource = ds.Tables(1)
Me.grdList.DataBind()
ViewState("DocListTable") = dts.Tables(1)
Dim ddl1 As DropDownList = DirectCast(grdDocList.Rows(0).Cells(1).FindControl("StudentName"), DropDownList)
FillDropDownList(ddl1)
end if