I have a templated column with a checkbox in it:
<igtbl:TemplatedColumn Key="CamBan" AllowUpdate="Yes" Width="5.55%"> <CellTemplate> <asp:CheckBox ID="cbCamBan" runat="server" Text="Ban" /> </CellTemplate> </igtbl:TemplatedColumn>
I could have used column with checkbox cell type, but you cannot add text to those checkboxes and these checkboxes are in multiple bands and i'm hiding the headers.
So i have gone with a templated column with an asp control in it. Finding if this control was checked on a server-side postback was a little difficult, but was accomplished with the following code:
Dim tempCol As Infragistics.WebUI.UltraWebGrid.TemplatedColumn Dim checkBox As System.Web.UI.WebControls.CheckBox Dim cObjs As ArrayList Dim cItems As Infragistics.WebUI.UltraWebGrid.CellItem tempCol = UltraWebGrid1.Rows(1).Rows(0).Cells(9).Column cObjs = tempCol.CellItems For Each item As Object In cObjs cItems = CType(item, Infragistics.WebUI.UltraWebGrid.CellItem) checkBox = cItems.FindControl("cbCamBan") If checkBox IsNot Nothing Then Dim cell As Infragistics.WebUI.UltraWebGrid.UltraGridCell = cItems.Cell If checkBox.Checked Then ' Response.Write(cell.Row.Cells(0).Value & " ") Else ' Do something else
End If
End If Next
i have to access the cellitems that belong to the templated column. Then i can use the findControl() method. I would like to loop through the rows and use the findcontrol on a ultragridcell object.
eg.
For each dr as ultragridrow in grid1.rows
dr.cells(0).item(0).findControl
' or something like that.
next
Help? thanks. :)
A generic findcontrol function could be useful;
function findControl(tagName, controlId) { var aControls = document.getElementsByTagName(tagName); if (aControls==null) return null; for (var i = 0; i < aControls.length; i++) { var ctl = aControls; if (ctl && ctl.id) { var subId = ctl.id.substring(ctl.id.length - controlId.length); if (subId == controlId) { return ctl; }}} return null;}