P
PD
I'm trying to add a new row to a datagrid object. See code below:
Private Sub dgImageList_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgImageList.ItemCreated
If e.Item.ItemType = ListItemType.Item Then
Dim tc As TableCell = New TableCell
Dim strFundTypeCd As String = "Testing"
tc.Controls.Add(New LiteralControl(strFundTypeCd))
tc.ColumnSpan = 6
tc.ID = "tc11" & e.Item.ItemIndex
Dim di As DataGridItem = New DataGridItem(e.Item.ItemIndex + 1, 0,
ListItemType.Item)
di.BorderStyle = BorderStyle.Groove
di.Cells.Add(tc)
Dim tb As Table = dgImageList.Controls(0)
tb.Rows.Add(di)
End If
When I view the source, I notice there is a <tr> row object that is
added to the grid, but no <td> cell is in it. Hence, there is no data
displayed and the row is empty. Here is the HTML source of the page
showing the <tr> row.
<tr valign="Middle" style="border-color:Black;border-style:Groove;">
</tr>
As you can see, no <td> tag.
The grid has already been data bound at this point, so I'm not sure if
that has something to do with it. I have tried placing the code in the
ItemDataBound event of the grid as well. Same results.
Adding the row to the dataset is not an option as well as I need to
build the grid dynamically.
Any suggestions would be greatly appreciated.
Patrick
Private Sub dgImageList_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgImageList.ItemCreated
If e.Item.ItemType = ListItemType.Item Then
Dim tc As TableCell = New TableCell
Dim strFundTypeCd As String = "Testing"
tc.Controls.Add(New LiteralControl(strFundTypeCd))
tc.ColumnSpan = 6
tc.ID = "tc11" & e.Item.ItemIndex
Dim di As DataGridItem = New DataGridItem(e.Item.ItemIndex + 1, 0,
ListItemType.Item)
di.BorderStyle = BorderStyle.Groove
di.Cells.Add(tc)
Dim tb As Table = dgImageList.Controls(0)
tb.Rows.Add(di)
End If
When I view the source, I notice there is a <tr> row object that is
added to the grid, but no <td> cell is in it. Hence, there is no data
displayed and the row is empty. Here is the HTML source of the page
showing the <tr> row.
<tr valign="Middle" style="border-color:Black;border-style:Groove;">
</tr>
As you can see, no <td> tag.
The grid has already been data bound at this point, so I'm not sure if
that has something to do with it. I have tried placing the code in the
ItemDataBound event of the grid as well. Same results.
Adding the row to the dataset is not an option as well as I need to
build the grid dynamically.
Any suggestions would be greatly appreciated.
Patrick