Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
535
Getting to the control in a templated column
posted

I have a link button inside a templated column that I need to change the visibility based on the data. I've tried:

protected void gridTracking_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e)

{

TemplatedColumn
col = (TemplatedColumn)e.Row.Cells.FromKey("Actions").Column;

CellItem ci = (CellItem)col.CellItems[0];

LinkButton archive = (LinkButton)ci.FindControl("btnArchiveTrackForm");

but archive always points to the SAME linkbutton... the one in the first row. Am I missing something? thanks!

Parents
No Data
Reply
  • 28464
    posted

    You can hook custom event handlers in the various events of the nested controls inside the template and hide/show/populate them based on certain criteria. In the example below. I am hiding all dropdowns with the exception of the dropdown in the third row:

    <igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server" Height="200px" Width="325px"
            DataSourceID="AccessDataSource1" >
            <Bands>
                <igtbl:UltraGridBand>
                    <Columns> 
                        <igtbl:TemplatedColumn>
                            <CellTemplate>
                                <asp:DropDownList
                                    runat="server"
                                    ID="DropDownList1"
                                    OnInit="DropDownList1_OnInit">
                                </asp:DropDownList>
                            </CellTemplate>
                        </igtbl:TemplatedColumn>                 
                    </Columns>               
                </igtbl:UltraGridBand>
            </Bands>
            ...
    </igtbl:UltraWebGrid>
           
        protected void DropDownList1_OnInit(object sender, EventArgs e)
        {
            DropDownList dropDownList = sender as DropDownList;
            CellItem parentCell = (CellItem) dropDownList.NamingContainer;

            if (parentCell.Cell.Row.BandIndex != 3)
            {
                dropDownList.Visible = false;
            }       
        }

    Hope this helps.
Children