G
Guest
Hi All,
I've dynmaically created a textbox, but I can't edit it. When I click on
it, the cursor flashes for a second, but then goes away and I can't enter any
text or do anything with the value in the box.
Here's the code I've used to create the control. It's within a datagrid
that is bound to a dataTable so the action happens in the ItemDataBound event.
Private Sub dgItems_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgItems.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim dtItems As New DataTable
dtItems = CType(Session("ItemsDT"), DataTable)
'this is what I can't edit
Dim txtQty As New TextBox
Page.Controls.Add(txtQty)
e.Item.Cells(0).Controls.Add(txtQty)
txtQty.ID = "txtQty" & e.Item.ItemIndex
txtQty.EnableViewState = True
txtQty.Text = dtItems.Rows(e.Item.DataSetIndex)(0)
txtQty.Width = WebControls.Unit.Pixel(30)
Dim lblDesc As New Label
lblDesc.EnableViewState = True
lblDesc.Text = dtItems.Rows(e.Item.DataSetIndex)(1)
e.Item.Cells(1).Controls.Add(lblDesc)
Dim lblUnitPrice As New Label
lblUnitPrice.EnableViewState = True
lblUnitPrice.Text = dtItems.Rows(e.Item.DataSetIndex)(2)
e.Item.Cells(2).Controls.Add(lblUnitPrice)
End If
End Sub
Thanks.
I've dynmaically created a textbox, but I can't edit it. When I click on
it, the cursor flashes for a second, but then goes away and I can't enter any
text or do anything with the value in the box.
Here's the code I've used to create the control. It's within a datagrid
that is bound to a dataTable so the action happens in the ItemDataBound event.
Private Sub dgItems_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgItems.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim dtItems As New DataTable
dtItems = CType(Session("ItemsDT"), DataTable)
'this is what I can't edit
Dim txtQty As New TextBox
Page.Controls.Add(txtQty)
e.Item.Cells(0).Controls.Add(txtQty)
txtQty.ID = "txtQty" & e.Item.ItemIndex
txtQty.EnableViewState = True
txtQty.Text = dtItems.Rows(e.Item.DataSetIndex)(0)
txtQty.Width = WebControls.Unit.Pixel(30)
Dim lblDesc As New Label
lblDesc.EnableViewState = True
lblDesc.Text = dtItems.Rows(e.Item.DataSetIndex)(1)
e.Item.Cells(1).Controls.Add(lblDesc)
Dim lblUnitPrice As New Label
lblUnitPrice.EnableViewState = True
lblUnitPrice.Text = dtItems.Rows(e.Item.DataSetIndex)(2)
e.Item.Cells(2).Controls.Add(lblUnitPrice)
End If
End Sub
Thanks.