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;}
The cells don't have a link back to the CellItems collection because they don't really know anything about the grid's templating. You should be able to use their index as an index into the CellItems collection if you want to iterate through the rows rather than through the cell items.
Helen
If it suits your situation, UpdateRowBatch is probably the easiest way to go (example assumes checkbox is in cell 1):
protected void ucgrdSearchResults_UpdateRowBatch(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e) { //Make sure the user selected the row. if (e.Row.Cells[1].Value.ToString() == "true") {
//Do something
}
This will only find data that has changed....