Hi,
I have a problem with TemplatedColumn. I am having a tree control and ultrawebgrid. If user clicks on a tree element, the grid is dynamically loaded with TemplatedColumn inside. The code looks like this:
uwg_Grid.ResetRows()uwg_Grid.ResetColumns()uwg_Grid.Clear()uwg_Grid.Columns.Add(New Infragistics.WebUI.UltraWebGrid.UltraGridColumn("ID", "ID", Infragistics.WebUI.UltraWebGrid.ColumnType.NotSet, ""), True)Dim col As New Infragistics.WebUI.UltraWebGrid.TemplatedColumncol.Key = "template"col.HeaderText = "Column"col.CellTemplate = New PropertyTemplate(str_AssemblyName, str_NameSpace)
uwg_Grid.Columns.Insert(uwg_Grid.Bands(0).Columns.Count, col)
Inside PropertyTemplate class I am implementing InstantiateIn method where I am adding new TextBox to the cells. The problem is that if you enter something into any textbox in that TemplatedColumn, and click another tree element the above code will run which should clear the webgrid and recreate it from the scratch with empty values in cells, but somehow the value you have entered still exists. Do I need to perform some additional clearing of the TemplatedColumn ?
Thanks in advance
Bartek
Hello Feniks,
So we have progress :) Unfortunately at this point it is really very hard for me to help further, since this could be related to many things and it really depends on custom code - that may affect the lifecycle of the page and events trigger in some way.
In cases like that, I believe the best approach would be to contact Developer Support directly with a small subset of your project reproducing the issue. They can be reached via the following link:
http://devcenter.infragistics.com/Protected/SubmitSupportIssue.aspx
I've followed one of the example from the Infragistics site about creating TemplatedColumn. It was written that "The WebGrid does not maintain column template data in the viewstate. Because of this, we have to manually keep track of text typed directly into the cell. When the updateCellBatch event fires for the text cell, it is our only opportunity to get a reference to the data in the cell"
and so I added
Private Sub grid_UpdateCellBatch(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.CellEventArgs) Handles grid.UpdateCellBatch If e.Cell.Column.Key = "template" Then
.....
End Sub
The problem now is that this method is called only for normal ultrawebgrid cells, changes in TemplatedColumn aren't noticed.
Both solutions didn't work. However I found you are setting control ID which I didn't do. Now I have:
Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements System.Web.UI.ITemplate.InstantiateIn
Dim cellitem As Infragistics.WebUI.UltraWebGrid.CellItem = CType(container, Infragistics.WebUI.UltraWebGrid.Cel
Dim tb_Field As System.Web.UI.WebControls.TextBox = New System.Web.UI.WebControls.TextBox()tb_Field.Text = cellitem.Cell.Row.Cells.FromKey("Value").Valuetb_Field.ID = str_ControlID & ":" & cellitem.Cell.Row.Cells.FromKey("Text").Valuecellitem.Controls.Add(tb_Field)
ID is quite unique now. This helped and I was very glad up to a moment when I tried to get values from those text boxes. I can easily take values from the other columns but :
Dim col As Infragistics.WebUI.UltraWebGrid.TemplatedColumn = obj_Row.Cells(1).Column
col.CellItems is empty :(
You can try with HtmlInputText instead of TextBox. Another thing you can try is setting the EnableViewState property of the TextBox to false.
using System.Web.UI.HtmlControls; HtmlInputText inputText = new HtmlInputText();inputText.ID = "HtmlInput1";
That's bad. How could I create a html control from the asp vb level ? I just need the ability to enter some text to the cell of TemplatedColumn and save it to xml at some point. Maybe I could use another control than TextBox to achieve that ?
ThanksBartek