I want to add an attribute to a button that is displayed on a band in the WHDG. The problem is that I don't know how to do this. I have tried the FindControl method at several levels, but I haven't been able to locate the control I am looking for (instead I just got an error).
The configuration of the grid is pretty simple: I have parent items that contain just one level of bands. In those bands I need to add ann attribute to the first item.
I am trying it with code like this:
Dim imBut As ImageButton = Me.MyWebHierarchicalDataGrid.GridView.Rows(0).Items(0).FindControl("MyImageButton")
This does result in imBut being Nothing.
However, when I read the property Me.MyWebHierarchicalDataGrid.GridView.Rows(0).Items(0).Column.Key I do in fact read that the key of the column is equal to the key of the TemplateDataField.
This is the code how the Band is made:
<Bands> <ig:Band AutoGenerateColumns="False" Key="MyBand" DataMember="MyCollection"> <Columns> <ig:TemplateDataField Key="DisableButton" Width="25px"> <ItemTemplate> <asp:ImageButton ID="MyImageButton" runat="server" CommandArgument='<%# DataBinder.Eval(CType(Container, Infragistics.Web.UI.TemplateContainer).DataItem, "ID") %>' ToolTip="Disable this item" CausesValidation="false" ImageUrl="~/Resources/Delete.png" /> </ItemTemplate> </ig:TemplateDataField> </Columns> </ig:Band></Bands>
Hi dvanmil,
If you are trying to use FindControl, make sure you use it on an actual container grid, not on a band. Is your button in an item template or templated column? Could you post the code you are trying?
regards,David Young