Getting values from dynamically created template columns in gridview
hi,
in my gridview i have some bound columns,and some template columns.and three columns dynamically added to the same gridview on the button click event.
code for dynamic created columns like this
For Each col As DataColumn In dtttt.Columns
For Each row As DataRow In dtt.Rows
If col.ColumnName = row.Item("CODE") Then
Dim customField1 As New TemplateField()
customField1.ShowHeader = True
customField1.HeaderTemplate = New Gridviewtemplate(DataControlRowType.Header, col.ColumnName, "", "label")
customField1.ItemTemplate = New Gridviewtemplate(DataControlRowType.DataRow, "", col.ColumnName, "Textbox")
DGV1.Columns.Add(customField1)
End If
Next
Next
DGV1.DataSource = dtttt
DGV1.DataBind()
but when the time of accessing the values of gridview except dynamically created template column values are not working
For i As Integer = 0 To DGV1.Rows.Count - 1
For count As Integer = 9 To DGV1.Columns.Count - 1
Try
dggrow = DGV1.Rows(i)
Select Case Incomes(Index)
Case 1
Earnings += CInt(dggrow.Cells(count).Text * Days)
Case 2
Earnings += CInt(dggrow.Cells(count).Text)
Case 3
Earnings -= CInt(dggrow.Cells(count).Text)
End Select
Catch ex As Exception
dggrow.Cells(count).Text = 0
End Try
Index += 1
Next
Next
dggrow.Cells(count).Text- here its not getting the value of dynamic created template column value.
how to access this value.anyone help me with this.this is very urgent.